@phantom/server-sdk 1.0.0-beta.2 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -86,8 +86,8 @@ dotenv.config();
86
86
  // Initialize the SDK
87
87
  const sdk = new ServerSDK({
88
88
  organizationId: process.env.ORGANIZATION_ID!,
89
+ appId: process.env.APP_ID!,
89
90
  apiPrivateKey: process.env.PRIVATE_KEY!,
90
- apiBaseUrl: process.env.API_URL!,
91
91
  });
92
92
 
93
93
  // Create a wallet
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ interface WalletAddress {
13
13
  interface ServerSDKConfig {
14
14
  organizationId: string;
15
15
  appId: string;
16
- apiBaseUrl: string;
16
+ apiBaseUrl?: string;
17
17
  apiPrivateKey: string;
18
18
  }
19
19
  interface ServerSignMessageParams {
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  ApiKeyStamper: () => import_api_key_stamper2.ApiKeyStamper,
34
34
  DerivationPath: () => import_client2.DerivationPath,
35
- NetworkId: () => import_constants.NetworkId,
35
+ NetworkId: () => import_constants2.NetworkId,
36
36
  PhantomClient: () => import_client2.PhantomClient,
37
37
  ServerSDK: () => ServerSDK,
38
38
  deriveSubmissionConfig: () => import_client2.deriveSubmissionConfig,
@@ -50,24 +50,102 @@ __export(src_exports, {
50
50
  });
51
51
  module.exports = __toCommonJS(src_exports);
52
52
  var import_client = require("@phantom/client");
53
+ var import_constants = require("@phantom/constants");
53
54
  var import_api_key_stamper = require("@phantom/api-key-stamper");
54
55
  var import_base64url = require("@phantom/base64url");
55
56
  var import_bs58 = __toESM(require("bs58"));
57
+
58
+ // package.json
59
+ var package_default = {
60
+ name: "@phantom/server-sdk",
61
+ version: "1.0.0-beta.3",
62
+ description: "Server SDK for Phantom Wallet",
63
+ main: "dist/index.js",
64
+ module: "dist/index.mjs",
65
+ types: "dist/index.d.ts",
66
+ exports: {
67
+ ".": {
68
+ import: "./dist/index.mjs",
69
+ require: "./dist/index.js",
70
+ types: "./dist/index.d.ts"
71
+ }
72
+ },
73
+ scripts: {
74
+ "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
75
+ "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
76
+ build: "rimraf ./dist && tsup",
77
+ dev: "tsc --watch",
78
+ clean: "rm -rf dist",
79
+ test: "jest",
80
+ "test:watch": "jest --watch",
81
+ lint: "eslint src --ext .ts,.tsx",
82
+ "check-types": "yarn tsc --noEmit",
83
+ prettier: 'prettier --write "src/**/*.{ts,tsx}"'
84
+ },
85
+ devDependencies: {
86
+ "@types/jest": "^29.5.12",
87
+ "@types/node": "^20.11.0",
88
+ dotenv: "^16.4.1",
89
+ eslint: "8.53.0",
90
+ jest: "^29.7.0",
91
+ prettier: "^3.5.2",
92
+ rimraf: "^6.0.1",
93
+ "ts-jest": "^29.1.2",
94
+ tsup: "^6.7.0",
95
+ typescript: "^5.0.4"
96
+ },
97
+ dependencies: {
98
+ "@phantom/api-key-stamper": "workspace:^",
99
+ "@phantom/base64url": "workspace:^",
100
+ "@phantom/client": "workspace:^",
101
+ "@phantom/constants": "workspace:^",
102
+ "@phantom/parsers": "workspace:^",
103
+ bs58: "^6.0.0"
104
+ },
105
+ files: [
106
+ "dist"
107
+ ],
108
+ publishConfig: {
109
+ directory: "_release/package"
110
+ }
111
+ };
112
+
113
+ // src/index.ts
56
114
  var import_parsers = require("@phantom/parsers");
57
115
  var import_client2 = require("@phantom/client");
58
- var import_constants = require("@phantom/constants");
116
+ var import_constants2 = require("@phantom/constants");
59
117
  var import_api_key_stamper2 = require("@phantom/api-key-stamper");
60
118
  var import_parsers2 = require("@phantom/parsers");
119
+ function getNodeVersion() {
120
+ if (typeof process !== "undefined" && process.version) {
121
+ return process.version;
122
+ }
123
+ return "unknown";
124
+ }
125
+ function getSdkVersion() {
126
+ return package_default.version || "unknown";
127
+ }
128
+ function createServerSdkHeaders(appId) {
129
+ return {
130
+ [import_constants.ANALYTICS_HEADERS.SDK_TYPE]: "server",
131
+ [import_constants.ANALYTICS_HEADERS.SDK_VERSION]: getSdkVersion(),
132
+ [import_constants.ANALYTICS_HEADERS.PLATFORM]: `node`,
133
+ [import_constants.ANALYTICS_HEADERS.PLATFORM_VERSION]: `${getNodeVersion()}`,
134
+ [import_constants.ANALYTICS_HEADERS.APP_ID]: appId
135
+ };
136
+ }
61
137
  var ServerSDK = class {
62
138
  constructor(config) {
63
139
  this.config = config;
64
140
  const stamper = new import_api_key_stamper.ApiKeyStamper({
65
141
  apiSecretKey: config.apiPrivateKey
66
142
  });
143
+ const headers = createServerSdkHeaders(config.appId);
67
144
  this.client = new import_client.PhantomClient(
68
145
  {
69
- apiBaseUrl: config.apiBaseUrl,
70
- organizationId: config.organizationId
146
+ apiBaseUrl: config.apiBaseUrl || import_constants.DEFAULT_WALLET_API_URL,
147
+ organizationId: config.organizationId,
148
+ headers
71
149
  },
72
150
  stamper
73
151
  );
@@ -121,10 +199,12 @@ var ServerSDK = class {
121
199
  return await (0, import_parsers.parseTransactionResponse)(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
122
200
  }
123
201
  createOrganization(name, keyPair) {
202
+ const headers = createServerSdkHeaders(this.config.appId);
124
203
  const tempClient = new import_client.PhantomClient(
125
204
  {
126
- apiBaseUrl: this.config.apiBaseUrl,
127
- organizationId: this.config.organizationId
205
+ apiBaseUrl: this.config.apiBaseUrl || import_constants.DEFAULT_WALLET_API_URL,
206
+ organizationId: this.config.organizationId,
207
+ headers
128
208
  },
129
209
  new import_api_key_stamper.ApiKeyStamper({
130
210
  apiSecretKey: keyPair.secretKey
package/dist/index.mjs CHANGED
@@ -2,9 +2,70 @@
2
2
  import {
3
3
  PhantomClient
4
4
  } from "@phantom/client";
5
+ import {
6
+ ANALYTICS_HEADERS,
7
+ DEFAULT_WALLET_API_URL
8
+ } from "@phantom/constants";
5
9
  import { ApiKeyStamper } from "@phantom/api-key-stamper";
6
10
  import { base64urlEncode } from "@phantom/base64url";
7
11
  import bs58 from "bs58";
12
+
13
+ // package.json
14
+ var package_default = {
15
+ name: "@phantom/server-sdk",
16
+ version: "1.0.0-beta.3",
17
+ description: "Server SDK for Phantom Wallet",
18
+ main: "dist/index.js",
19
+ module: "dist/index.mjs",
20
+ types: "dist/index.d.ts",
21
+ exports: {
22
+ ".": {
23
+ import: "./dist/index.mjs",
24
+ require: "./dist/index.js",
25
+ types: "./dist/index.d.ts"
26
+ }
27
+ },
28
+ scripts: {
29
+ "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
30
+ "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
31
+ build: "rimraf ./dist && tsup",
32
+ dev: "tsc --watch",
33
+ clean: "rm -rf dist",
34
+ test: "jest",
35
+ "test:watch": "jest --watch",
36
+ lint: "eslint src --ext .ts,.tsx",
37
+ "check-types": "yarn tsc --noEmit",
38
+ prettier: 'prettier --write "src/**/*.{ts,tsx}"'
39
+ },
40
+ devDependencies: {
41
+ "@types/jest": "^29.5.12",
42
+ "@types/node": "^20.11.0",
43
+ dotenv: "^16.4.1",
44
+ eslint: "8.53.0",
45
+ jest: "^29.7.0",
46
+ prettier: "^3.5.2",
47
+ rimraf: "^6.0.1",
48
+ "ts-jest": "^29.1.2",
49
+ tsup: "^6.7.0",
50
+ typescript: "^5.0.4"
51
+ },
52
+ dependencies: {
53
+ "@phantom/api-key-stamper": "workspace:^",
54
+ "@phantom/base64url": "workspace:^",
55
+ "@phantom/client": "workspace:^",
56
+ "@phantom/constants": "workspace:^",
57
+ "@phantom/parsers": "workspace:^",
58
+ bs58: "^6.0.0"
59
+ },
60
+ files: [
61
+ "dist"
62
+ ],
63
+ publishConfig: {
64
+ directory: "_release/package"
65
+ }
66
+ };
67
+
68
+ // src/index.ts
8
69
  import {
9
70
  parseMessage,
10
71
  parseTransactionToBase64Url,
@@ -31,16 +92,36 @@ import {
31
92
  parseSignMessageResponse as parseSignMessageResponse2,
32
93
  parseTransactionResponse as parseTransactionResponse2
33
94
  } from "@phantom/parsers";
95
+ function getNodeVersion() {
96
+ if (typeof process !== "undefined" && process.version) {
97
+ return process.version;
98
+ }
99
+ return "unknown";
100
+ }
101
+ function getSdkVersion() {
102
+ return package_default.version || "unknown";
103
+ }
104
+ function createServerSdkHeaders(appId) {
105
+ return {
106
+ [ANALYTICS_HEADERS.SDK_TYPE]: "server",
107
+ [ANALYTICS_HEADERS.SDK_VERSION]: getSdkVersion(),
108
+ [ANALYTICS_HEADERS.PLATFORM]: `node`,
109
+ [ANALYTICS_HEADERS.PLATFORM_VERSION]: `${getNodeVersion()}`,
110
+ [ANALYTICS_HEADERS.APP_ID]: appId
111
+ };
112
+ }
34
113
  var ServerSDK = class {
35
114
  constructor(config) {
36
115
  this.config = config;
37
116
  const stamper = new ApiKeyStamper({
38
117
  apiSecretKey: config.apiPrivateKey
39
118
  });
119
+ const headers = createServerSdkHeaders(config.appId);
40
120
  this.client = new PhantomClient(
41
121
  {
42
- apiBaseUrl: config.apiBaseUrl,
43
- organizationId: config.organizationId
122
+ apiBaseUrl: config.apiBaseUrl || DEFAULT_WALLET_API_URL,
123
+ organizationId: config.organizationId,
124
+ headers
44
125
  },
45
126
  stamper
46
127
  );
@@ -94,10 +175,12 @@ var ServerSDK = class {
94
175
  return await parseTransactionResponse(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
95
176
  }
96
177
  createOrganization(name, keyPair) {
178
+ const headers = createServerSdkHeaders(this.config.appId);
97
179
  const tempClient = new PhantomClient(
98
180
  {
99
- apiBaseUrl: this.config.apiBaseUrl,
100
- organizationId: this.config.organizationId
181
+ apiBaseUrl: this.config.apiBaseUrl || DEFAULT_WALLET_API_URL,
182
+ organizationId: this.config.organizationId,
183
+ headers
101
184
  },
102
185
  new ApiKeyStamper({
103
186
  apiSecretKey: keyPair.secretKey
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/server-sdk",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Server SDK for Phantom Wallet",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,7 +15,7 @@
15
15
  "scripts": {
16
16
  "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
17
17
  "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
18
- "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts",
18
+ "build": "rimraf ./dist && tsup",
19
19
  "dev": "tsc --watch",
20
20
  "clean": "rm -rf dist",
21
21
  "test": "jest",
@@ -37,11 +37,11 @@
37
37
  "typescript": "^5.0.4"
38
38
  },
39
39
  "dependencies": {
40
- "@phantom/api-key-stamper": "^1.0.0-beta.2",
41
- "@phantom/base64url": "^1.0.0-beta.2",
42
- "@phantom/client": "^1.0.0-beta.2",
43
- "@phantom/constants": "^1.0.0-beta.2",
44
- "@phantom/parsers": "^1.0.0-beta.2",
40
+ "@phantom/api-key-stamper": "^1.0.0-beta.3",
41
+ "@phantom/base64url": "^1.0.0-beta.3",
42
+ "@phantom/client": "^1.0.0-beta.3",
43
+ "@phantom/constants": "^1.0.0-beta.3",
44
+ "@phantom/parsers": "^1.0.0-beta.3",
45
45
  "bs58": "^6.0.0"
46
46
  },
47
47
  "files": [