@mysten/enoki 0.3.16 → 0.4.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mysten/enoki
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f589885: Add sdk methods for managing enoki subnames
8
+
9
+ ## 0.3.17
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [143cd9d]
14
+ - Updated dependencies [4357ac6]
15
+ - Updated dependencies [4019dd7]
16
+ - Updated dependencies [4019dd7]
17
+ - Updated dependencies [00a974d]
18
+ - @mysten/sui@1.7.0
19
+ - @mysten/zklogin@0.7.17
20
+
3
21
  ## 0.3.16
4
22
 
5
23
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
1
+ import type { CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateSubnameApiInput, CreateSubnameApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, DeleteSubnameApiInput, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetSubnamesApiInput, GetSubnamesApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
2
2
  export interface EnokiClientConfig {
3
3
  /** The API key for the Enoki app, available in the Enoki Portal. */
4
4
  apiKey: string;
@@ -11,6 +11,8 @@ export declare class EnokiClientError extends Error {
11
11
  message: string;
12
12
  data: unknown;
13
13
  }[];
14
+ status: number;
15
+ code: string;
14
16
  constructor(status: number, response: string);
15
17
  }
16
18
  /**
@@ -25,4 +27,7 @@ export declare class EnokiClient {
25
27
  createZkLoginZkp(input: CreateZkLoginZkpApiInput): Promise<CreateZkLoginZkpApiResponse>;
26
28
  createSponsoredTransaction(input: CreateSponsoredTransactionApiInput): Promise<CreateSponsoredTransactionApiResponse>;
27
29
  executeSponsoredTransaction(input: ExecuteSponsoredTransactionApiInput): Promise<ExecuteSponsoredTransactionApiResponse>;
30
+ getSubnames(input: GetSubnamesApiInput): Promise<GetSubnamesApiResponse>;
31
+ createSubname(input: CreateSubnameApiInput): Promise<CreateSubnameApiResponse>;
32
+ deleteSubname(input: DeleteSubnameApiInput): void;
28
33
  }
@@ -48,6 +48,8 @@ class EnokiClientError extends Error {
48
48
  this.errors = [];
49
49
  this.errors = errors ?? [];
50
50
  this.name = "EnokiClientError";
51
+ this.status = status;
52
+ this.code = errors?.[0]?.code ?? "unknown_error";
51
53
  }
52
54
  }
53
55
  class EnokiClient {
@@ -120,6 +122,45 @@ class EnokiClient {
120
122
  })
121
123
  });
122
124
  }
125
+ getSubnames(input) {
126
+ const query = new URLSearchParams();
127
+ if (input.address) {
128
+ query.set("address", input.address);
129
+ }
130
+ if (input.network) {
131
+ query.set("network", input.network);
132
+ }
133
+ if (input.domain) {
134
+ query.set("domain", input.domain);
135
+ }
136
+ return __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames" + (query.size > 0 ? `?${query.toString()}` : ""), {
137
+ method: "GET"
138
+ });
139
+ }
140
+ createSubname(input) {
141
+ return __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames", {
142
+ method: "POST",
143
+ headers: input.jwt ? {
144
+ [ZKLOGIN_HEADER]: input.jwt
145
+ } : {},
146
+ body: JSON.stringify({
147
+ network: input.network,
148
+ domain: input.domain,
149
+ subname: input.subname,
150
+ targetAddress: input.targetAddress
151
+ })
152
+ });
153
+ }
154
+ deleteSubname(input) {
155
+ __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames", {
156
+ method: "DELETE",
157
+ body: JSON.stringify({
158
+ network: input.network,
159
+ domain: input.domain,
160
+ subname: input.subname
161
+ })
162
+ });
163
+ }
123
164
  }
124
165
  _version = new WeakMap();
125
166
  _apiUrl = new WeakMap();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/EnokiClient/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tCreateSponsoredTransactionApiInput,\n\tCreateSponsoredTransactionApiResponse,\n\tCreateZkLoginNonceApiInput,\n\tCreateZkLoginNonceApiResponse,\n\tCreateZkLoginZkpApiInput,\n\tCreateZkLoginZkpApiResponse,\n\tExecuteSponsoredTransactionApiInput,\n\tExecuteSponsoredTransactionApiResponse,\n\tGetAppApiInput,\n\tGetAppApiResponse,\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\nexport class EnokiClientError extends Error {\n\terrors: { code: string; message: string; data: unknown }[] = [];\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 (e) {\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}\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\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}\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\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,\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\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAUhB,MAAM,yBAAyB,MAAM;AAAA,EAG3C,YAAY,QAAgB,UAAkB;AAC7C,QAAI;AACJ,QAAI;AACH,YAAM,iBAAiB,KAAK,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SponsoredTransactionApiInput,\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\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\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 (e) {\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\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}\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\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,\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAUhB,MAAM,yBAAyB,MAAM;AAAA,EAK3C,YAAY,QAAgB,UAAkB;AAC7C,QAAI;AACJ,QAAI;AACH,YAAM,iBAAiB,KAAK,MAAM,QAAQ;AAG1C,eAAS,eAAe;AAAA,IACzB,SAAS,GAAG;AAAA,IAEZ;AACA,UAAM,QAAQ,SAAS,CAAC,IAAI,IAAI,MAAM,OAAO,CAAC,EAAE,OAAO,IAAI;AAC3D,UAAM,wCAAwC,MAAM,KAAK;AAAA,MACxD;AAAA,IACD,CAAC;AAjBF,kBAA6D,CAAC;AAkB7D,SAAK,SAAS,UAAU,CAAC;AACzB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO,SAAS,CAAC,GAAG,QAAQ;AAAA,EAClC;AACD;AAKO,MAAM,YAAY;AAAA,EAKxB,YAAY,QAA2B;AALjC;AACN;AACA;AACA;AAGC,uBAAK,UAAW;AAChB,uBAAK,SAAU,OAAO,UAAU;A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,WAAmB,eAAC,MAAc,MAA+B;AACtE,QAAM,MAAM,MAAM,MAAM,GAAG,mBAAK,QAAO,IAAI,mBAAK,SAAQ,IAAI,IAAI,IAAI;AAAA,IACnE,GAAG;AAAA,IACH,SAAS;AAAA,MACR,GAAG,KAAK;AAAA,MACR,eAAe,UAAU,mBAAK,QAAO;AAAA,MACrC,gBAAgB;AAAA,MAChB,cAAc,OAAO,WAAW;AAAA,IACjC;AAAA,EACD,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACZ,UAAM,IAAI,iBAAiB,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC;AAAA,EACxD;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,IAAI,KAAK;AAEhC,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -2,13 +2,21 @@ import type { PublicKey } from '@mysten/sui/cryptography';
2
2
  import type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';
3
3
  import type { AuthProvider } from '../EnokiFlow.js';
4
4
  export type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';
5
+ export type EnokiDomainNetwork = 'mainnet' | 'testnet';
6
+ export type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';
5
7
  export interface GetAppApiInput {
6
8
  }
7
9
  export interface GetAppApiResponse {
10
+ allowedOrigins: string[];
8
11
  authenticationProviders: {
9
12
  providerType: AuthProvider;
10
13
  clientId: string;
11
14
  }[];
15
+ domains: {
16
+ nftId: string;
17
+ name: string;
18
+ network: EnokiDomainNetwork;
19
+ }[];
12
20
  }
13
21
  export interface GetZkLoginApiInput {
14
22
  jwt: string;
@@ -63,3 +71,36 @@ export interface ExecuteSponsoredTransactionApiInput {
63
71
  export interface ExecuteSponsoredTransactionApiResponse {
64
72
  digest: string;
65
73
  }
74
+ export interface GetSubnamesApiInput {
75
+ address?: string;
76
+ network?: EnokiDomainNetwork;
77
+ domain?: string;
78
+ }
79
+ export interface GetSubnamesApiResponse {
80
+ subnames: {
81
+ name: string;
82
+ status: EnokiSubanameStatus;
83
+ }[];
84
+ }
85
+ export type CreateSubnameApiInput = {
86
+ domain: string;
87
+ network?: EnokiDomainNetwork;
88
+ subname: string;
89
+ } & ({
90
+ jwt: string;
91
+ targetAddress?: never;
92
+ } | {
93
+ targetAddress: string;
94
+ jwt?: never;
95
+ });
96
+ export interface CreateSubnameApiResponse {
97
+ name: string;
98
+ }
99
+ export interface DeleteSubnameApiInput {
100
+ domain: string;
101
+ network?: EnokiDomainNetwork;
102
+ subname: string;
103
+ }
104
+ export interface DeleteSubnameApiResponse {
105
+ name: string;
106
+ }
@@ -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\nimport type { AuthProvider } from '../EnokiFlow.js';\n\nexport type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';\n\nexport interface GetAppApiInput {}\nexport interface GetAppApiResponse {\n\tauthenticationProviders: {\n\t\tproviderType: AuthProvider;\n\t\tclientId: string;\n\t}[];\n}\n\nexport interface GetZkLoginApiInput {\n\tjwt: string;\n}\nexport interface GetZkLoginApiResponse {\n\taddress: string;\n\tsalt: string;\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"],
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\nimport type { AuthProvider } from '../EnokiFlow.js';\n\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\tsalt: string;\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
  }
@@ -1,4 +1,4 @@
1
- export { EnokiClient, type EnokiClientConfig } from './EnokiClient/index.js';
1
+ export { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';
2
2
  export { EnokiFlow, type AuthProvider, type EnokiFlowConfig } from './EnokiFlow.js';
3
3
  export { createLocalStorage, createSessionStorage, createInMemoryStorage, type SyncStore, } from './stores.js';
4
4
  export { createDefaultEncryption, type Encryption } from './encryption.js';
package/dist/cjs/index.js CHANGED
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var src_exports = {};
20
20
  __export(src_exports, {
21
21
  EnokiClient: () => import_EnokiClient.EnokiClient,
22
+ EnokiClientError: () => import_EnokiClient.EnokiClientError,
22
23
  EnokiFlow: () => import_EnokiFlow.EnokiFlow,
23
24
  EnokiKeypair: () => import_EnokiKeypair.EnokiKeypair,
24
25
  EnokiPublicKey: () => import_EnokiKeypair.EnokiPublicKey,
@@ -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 } from './EnokiClient/index.js';\nexport { EnokiFlow, type AuthProvider, 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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAoD;AACpD,uBAAmE;AACnE,oBAKO;AACP,wBAAyD;AACzD,0BAA6C;",
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 { EnokiFlow, type AuthProvider, 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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAsE;AACtE,uBAAmE;AACnE,oBAKO;AACP,wBAAyD;AACzD,0BAA6C;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import type { CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
1
+ import type { CreateSponsoredTransactionApiInput, CreateSponsoredTransactionApiResponse, CreateSubnameApiInput, CreateSubnameApiResponse, CreateZkLoginNonceApiInput, CreateZkLoginNonceApiResponse, CreateZkLoginZkpApiInput, CreateZkLoginZkpApiResponse, DeleteSubnameApiInput, ExecuteSponsoredTransactionApiInput, ExecuteSponsoredTransactionApiResponse, GetAppApiInput, GetAppApiResponse, GetSubnamesApiInput, GetSubnamesApiResponse, GetZkLoginApiInput, GetZkLoginApiResponse } from './type.js';
2
2
  export interface EnokiClientConfig {
3
3
  /** The API key for the Enoki app, available in the Enoki Portal. */
4
4
  apiKey: string;
@@ -11,6 +11,8 @@ export declare class EnokiClientError extends Error {
11
11
  message: string;
12
12
  data: unknown;
13
13
  }[];
14
+ status: number;
15
+ code: string;
14
16
  constructor(status: number, response: string);
15
17
  }
16
18
  /**
@@ -25,4 +27,7 @@ export declare class EnokiClient {
25
27
  createZkLoginZkp(input: CreateZkLoginZkpApiInput): Promise<CreateZkLoginZkpApiResponse>;
26
28
  createSponsoredTransaction(input: CreateSponsoredTransactionApiInput): Promise<CreateSponsoredTransactionApiResponse>;
27
29
  executeSponsoredTransaction(input: ExecuteSponsoredTransactionApiInput): Promise<ExecuteSponsoredTransactionApiResponse>;
30
+ getSubnames(input: GetSubnamesApiInput): Promise<GetSubnamesApiResponse>;
31
+ createSubname(input: CreateSubnameApiInput): Promise<CreateSubnameApiResponse>;
32
+ deleteSubname(input: DeleteSubnameApiInput): void;
28
33
  }
@@ -24,6 +24,8 @@ class EnokiClientError extends Error {
24
24
  this.errors = [];
25
25
  this.errors = errors ?? [];
26
26
  this.name = "EnokiClientError";
27
+ this.status = status;
28
+ this.code = errors?.[0]?.code ?? "unknown_error";
27
29
  }
28
30
  }
29
31
  class EnokiClient {
@@ -96,6 +98,45 @@ class EnokiClient {
96
98
  })
97
99
  });
98
100
  }
101
+ getSubnames(input) {
102
+ const query = new URLSearchParams();
103
+ if (input.address) {
104
+ query.set("address", input.address);
105
+ }
106
+ if (input.network) {
107
+ query.set("network", input.network);
108
+ }
109
+ if (input.domain) {
110
+ query.set("domain", input.domain);
111
+ }
112
+ return __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames" + (query.size > 0 ? `?${query.toString()}` : ""), {
113
+ method: "GET"
114
+ });
115
+ }
116
+ createSubname(input) {
117
+ return __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames", {
118
+ method: "POST",
119
+ headers: input.jwt ? {
120
+ [ZKLOGIN_HEADER]: input.jwt
121
+ } : {},
122
+ body: JSON.stringify({
123
+ network: input.network,
124
+ domain: input.domain,
125
+ subname: input.subname,
126
+ targetAddress: input.targetAddress
127
+ })
128
+ });
129
+ }
130
+ deleteSubname(input) {
131
+ __privateMethod(this, _EnokiClient_instances, fetch_fn).call(this, "subnames", {
132
+ method: "DELETE",
133
+ body: JSON.stringify({
134
+ network: input.network,
135
+ domain: input.domain,
136
+ subname: input.subname
137
+ })
138
+ });
139
+ }
99
140
  }
100
141
  _version = new WeakMap();
101
142
  _apiUrl = new WeakMap();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/EnokiClient/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tCreateSponsoredTransactionApiInput,\n\tCreateSponsoredTransactionApiResponse,\n\tCreateZkLoginNonceApiInput,\n\tCreateZkLoginNonceApiResponse,\n\tCreateZkLoginZkpApiInput,\n\tCreateZkLoginZkpApiResponse,\n\tExecuteSponsoredTransactionApiInput,\n\tExecuteSponsoredTransactionApiResponse,\n\tGetAppApiInput,\n\tGetAppApiResponse,\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\nexport class EnokiClientError extends Error {\n\terrors: { code: string; message: string; data: unknown }[] = [];\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 (e) {\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}\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\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}\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\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,\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\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"],
5
- "mappings": ";;;;;;;;AAAA;AAkBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAUhB,MAAM,yBAAyB,MAAM;AAAA,EAG3C,YAAY,QAAgB,UAAkB;AAC7C,QAAI;AACJ,QAAI;AACH,YAAM,iBAAiB,KAAK,MAAM,QAAQ;AAG1C,eAAS,eAAe;AAAA,IACzB,SAAS,GAAG;AAAA,IAEZ;AACA,UAAM,QAAQ,SAAS,CAAC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OAA2C;AACrE,WAAO,sBAAK,kCAAL,WAAmD,8BAA8B;AAAA,MACvF,QAAQ;AAAA,MACR,SAAS,MAAM,MACZ;AAAA,QACA,CAAC,cAAc,GAAG,MAAM;AAAA,MACzB,IACC,CAAC;AAAA,MACJ,MAAM,KAAK,UAAU;AAAA,QACpB,QAAQ,MAAM;AAAA,QACd,SAAS,MAAM;AAAA,QACf,2BAA2B,MAAM;AAAA,QACjC,kBAAkB,MAAM;AAAA,QACxB,wBAAwB,MAAM;AAAA,MAC/B,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAEA,4BAA4B,OAA4C;AACvE,WAAO,sBAAK,kCAAL,WACN,8BAA8B,MAAM,MAAM,IAC1C;AAAA,MACC,QAAQ;AAAA,MACR,MAAM,KAAK,UAAU;AAAA,QACpB,WAAW,MAAM;AAAA,MAClB,CAAC;AAAA,IACF;AAAA,EAEF;AAqBD;AApGC;AACA;AACA;AAHM;AAkFA,WAAmB,eAAC,MAAc,MAA+B;AACtE,QAAM,MAAM,MAAM,MAAM,GAAG,mBAAK,QAAO,IAAI,mBAAK,SAAQ,IAAI,IAAI,IAAI;AAAA,IACnE,GAAG;AAAA,IACH,SAAS;AAAA,MACR,GAAG,KAAK;AAAA,MACR,eAAe,UAAU,mBAAK,QAAO;AAAA,MACrC,gBAAgB;AAAA,MAChB,cAAc,OAAO,WAAW;AAAA,IACjC;AAAA,EACD,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACZ,UAAM,IAAI,iBAAiB,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC;AAAA,EACxD;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,IAAI,KAAK;AAEhC,SAAO;AACR;",
4
+ "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\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\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 (e) {\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\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}\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\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,\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"],
5
+ "mappings": ";;;;;;;;AAAA;AAwBA,MAAM,kBAAkB;AACxB,MAAM,iBAAiB;AAUhB,MAAM,yBAAyB,MAAM;AAAA,EAK3C,YAAY,QAAgB,UAAkB;AAC7C,QAAI;AACJ,QAAI;AACH,YAAM,iBAAiB,KAAK,MAAM,QAAQ;AAG1C,eAAS,eAAe;AAAA,IACzB,SAAS,GAAG;AAAA,IAEZ;AACA,UAAM,QAAQ,SAAS,CAAC,IAAI,IAAI,MAAM,OAAO,CAAC,EAAE,OAAO,IAAI;AAC3D,UAAM,wCAAwC,MAAM,KAAK;AAAA,MACxD;AAAA,IACD,CAAC;AAjBF,kBAA6D,CAAC;AAkB7D,SAAK,SAAS,UAAU,CAAC;AACzB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO,SAAS,CAAC,GAAG,QAAQ;AAAA,EAClC;AACD;AAKO,MAAM,YAAY;AAAA,EAKxB,YAAY,QAA2B;AALjC;AACN;AACA;AACA;AAGC,uBAAK,UAAW;AAChB,uBAAK,SAAU,OAAO,UAAU;AAChC,uBAAK,SAAU,OAAO;AAAA,EACvB;AAAA,EAEA,OAAO,QAAyB;AAC/B,WAAO,sBAAK,kCAAL,WAA+B,OAAO;AAAA,MAC5C,QAAQ;AAAA,IACT;AAAA,EACD;AAAA,EAEA,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MACR,GAAG,KAAK;AAAA,MACR,eAAe,UAAU,mBAAK,QAAO;AAAA,MACrC,gBAAgB;AAAA,MAChB,cAAc,OAAO,WAAW;AAAA,IACjC;AAAA,EACD,CAAC;AAED,MAAI,CAAC,IAAI,IAAI;AACZ,UAAM,IAAI,iBAAiB,IAAI,QAAQ,MAAM,IAAI,KAAK,CAAC;AAAA,EACxD;AAEA,QAAM,EAAE,KAAK,IAAI,MAAM,IAAI,KAAK;AAEhC,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -2,13 +2,21 @@ import type { PublicKey } from '@mysten/sui/cryptography';
2
2
  import type { ZkLoginSignatureInputs } from '@mysten/sui/zklogin';
3
3
  import type { AuthProvider } from '../EnokiFlow.js';
4
4
  export type EnokiNetwork = 'mainnet' | 'testnet' | 'devnet';
5
+ export type EnokiDomainNetwork = 'mainnet' | 'testnet';
6
+ export type EnokiSubanameStatus = 'PENDING' | 'ACTIVE';
5
7
  export interface GetAppApiInput {
6
8
  }
7
9
  export interface GetAppApiResponse {
10
+ allowedOrigins: string[];
8
11
  authenticationProviders: {
9
12
  providerType: AuthProvider;
10
13
  clientId: string;
11
14
  }[];
15
+ domains: {
16
+ nftId: string;
17
+ name: string;
18
+ network: EnokiDomainNetwork;
19
+ }[];
12
20
  }
13
21
  export interface GetZkLoginApiInput {
14
22
  jwt: string;
@@ -63,3 +71,36 @@ export interface ExecuteSponsoredTransactionApiInput {
63
71
  export interface ExecuteSponsoredTransactionApiResponse {
64
72
  digest: string;
65
73
  }
74
+ export interface GetSubnamesApiInput {
75
+ address?: string;
76
+ network?: EnokiDomainNetwork;
77
+ domain?: string;
78
+ }
79
+ export interface GetSubnamesApiResponse {
80
+ subnames: {
81
+ name: string;
82
+ status: EnokiSubanameStatus;
83
+ }[];
84
+ }
85
+ export type CreateSubnameApiInput = {
86
+ domain: string;
87
+ network?: EnokiDomainNetwork;
88
+ subname: string;
89
+ } & ({
90
+ jwt: string;
91
+ targetAddress?: never;
92
+ } | {
93
+ targetAddress: string;
94
+ jwt?: never;
95
+ });
96
+ export interface CreateSubnameApiResponse {
97
+ name: string;
98
+ }
99
+ export interface DeleteSubnameApiInput {
100
+ domain: string;
101
+ network?: EnokiDomainNetwork;
102
+ subname: string;
103
+ }
104
+ export interface DeleteSubnameApiResponse {
105
+ name: string;
106
+ }
@@ -1,4 +1,4 @@
1
- export { EnokiClient, type EnokiClientConfig } from './EnokiClient/index.js';
1
+ export { EnokiClient, type EnokiClientConfig, EnokiClientError } from './EnokiClient/index.js';
2
2
  export { EnokiFlow, type AuthProvider, type EnokiFlowConfig } from './EnokiFlow.js';
3
3
  export { createLocalStorage, createSessionStorage, createInMemoryStorage, type SyncStore, } from './stores.js';
4
4
  export { createDefaultEncryption, type Encryption } from './encryption.js';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { EnokiClient } from "./EnokiClient/index.js";
1
+ import { EnokiClient, EnokiClientError } from "./EnokiClient/index.js";
2
2
  import { EnokiFlow } from "./EnokiFlow.js";
3
3
  import {
4
4
  createLocalStorage,
@@ -9,6 +9,7 @@ import { createDefaultEncryption } from "./encryption.js";
9
9
  import { EnokiKeypair, EnokiPublicKey } from "./EnokiKeypair.js";
10
10
  export {
11
11
  EnokiClient,
12
+ EnokiClientError,
12
13
  EnokiFlow,
13
14
  EnokiKeypair,
14
15
  EnokiPublicKey,
@@ -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 } from './EnokiClient/index.js';\nexport { EnokiFlow, type AuthProvider, 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"],
5
- "mappings": "AAGA,SAAS,mBAA2C;AACpD,SAAS,iBAA0D;AACnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,SAAS,+BAAgD;AACzD,SAAS,cAAc,sBAAsB;",
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 { EnokiFlow, type AuthProvider, 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"],
5
+ "mappings": "AAGA,SAAS,aAAqC,wBAAwB;AACtE,SAAS,iBAA0D;AACnE;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP,SAAS,+BAAgD;AACzD,SAAS,cAAc,sBAAsB;",
6
6
  "names": []
7
7
  }