@phantom/server-sdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -2
- package/dist/index.mjs +14 -2
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare class ServerSDK {
|
|
|
45
45
|
createOrganization(name: string, keyPair: {
|
|
46
46
|
publicKey: string;
|
|
47
47
|
secretKey: string;
|
|
48
|
-
}
|
|
48
|
+
}): Promise<Organization>;
|
|
49
49
|
getWallets(limit?: number, offset?: number): Promise<GetWalletsResult>;
|
|
50
50
|
createWallet(name: string): Promise<CreateWalletResult>;
|
|
51
51
|
getWalletAddresses(walletId: string, derivationPaths?: string[]): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -41,6 +51,8 @@ __export(src_exports, {
|
|
|
41
51
|
module.exports = __toCommonJS(src_exports);
|
|
42
52
|
var import_client = require("@phantom/client");
|
|
43
53
|
var import_api_key_stamper = require("@phantom/api-key-stamper");
|
|
54
|
+
var import_base64url = require("@phantom/base64url");
|
|
55
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
44
56
|
var import_parsers = require("@phantom/parsers");
|
|
45
57
|
var import_client2 = require("@phantom/client");
|
|
46
58
|
var import_constants = require("@phantom/constants");
|
|
@@ -90,7 +102,7 @@ var ServerSDK = class {
|
|
|
90
102
|
const rawResponse = await this.client.signAndSendTransaction(signAndSendParams);
|
|
91
103
|
return await (0, import_parsers.parseTransactionResponse)(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
|
|
92
104
|
}
|
|
93
|
-
createOrganization(name, keyPair
|
|
105
|
+
createOrganization(name, keyPair) {
|
|
94
106
|
const tempClient = new import_client.PhantomClient(
|
|
95
107
|
{
|
|
96
108
|
apiBaseUrl: this.config.apiBaseUrl,
|
|
@@ -100,7 +112,17 @@ var ServerSDK = class {
|
|
|
100
112
|
apiSecretKey: keyPair.secretKey
|
|
101
113
|
})
|
|
102
114
|
);
|
|
103
|
-
|
|
115
|
+
const base64urlPublicKey = (0, import_base64url.base64urlEncode)(import_bs58.default.decode(keyPair.publicKey));
|
|
116
|
+
return tempClient.createOrganization(name, [{
|
|
117
|
+
username: `user-${Date.now()}`,
|
|
118
|
+
role: "admin",
|
|
119
|
+
authenticators: [{
|
|
120
|
+
authenticatorName: `auth-${Date.now()}`,
|
|
121
|
+
authenticatorKind: "keypair",
|
|
122
|
+
publicKey: base64urlPublicKey,
|
|
123
|
+
algorithm: "Ed25519"
|
|
124
|
+
}]
|
|
125
|
+
}]);
|
|
104
126
|
}
|
|
105
127
|
getWallets(limit, offset) {
|
|
106
128
|
return this.client.getWallets(limit, offset);
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
PhantomClient
|
|
4
4
|
} from "@phantom/client";
|
|
5
5
|
import { ApiKeyStamper } from "@phantom/api-key-stamper";
|
|
6
|
+
import { base64urlEncode } from "@phantom/base64url";
|
|
7
|
+
import bs58 from "bs58";
|
|
6
8
|
import {
|
|
7
9
|
parseMessage,
|
|
8
10
|
parseTransaction,
|
|
@@ -73,7 +75,7 @@ var ServerSDK = class {
|
|
|
73
75
|
const rawResponse = await this.client.signAndSendTransaction(signAndSendParams);
|
|
74
76
|
return await parseTransactionResponse(rawResponse.rawTransaction, params.networkId, rawResponse.hash);
|
|
75
77
|
}
|
|
76
|
-
createOrganization(name, keyPair
|
|
78
|
+
createOrganization(name, keyPair) {
|
|
77
79
|
const tempClient = new PhantomClient(
|
|
78
80
|
{
|
|
79
81
|
apiBaseUrl: this.config.apiBaseUrl,
|
|
@@ -83,7 +85,17 @@ var ServerSDK = class {
|
|
|
83
85
|
apiSecretKey: keyPair.secretKey
|
|
84
86
|
})
|
|
85
87
|
);
|
|
86
|
-
|
|
88
|
+
const base64urlPublicKey = base64urlEncode(bs58.decode(keyPair.publicKey));
|
|
89
|
+
return tempClient.createOrganization(name, [{
|
|
90
|
+
username: `user-${Date.now()}`,
|
|
91
|
+
role: "admin",
|
|
92
|
+
authenticators: [{
|
|
93
|
+
authenticatorName: `auth-${Date.now()}`,
|
|
94
|
+
authenticatorKind: "keypair",
|
|
95
|
+
publicKey: base64urlPublicKey,
|
|
96
|
+
algorithm: "Ed25519"
|
|
97
|
+
}]
|
|
98
|
+
}]);
|
|
87
99
|
}
|
|
88
100
|
getWallets(limit, offset) {
|
|
89
101
|
return this.client.getWallets(limit, offset);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/server-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Server SDK for Phantom Wallet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,11 +37,13 @@
|
|
|
37
37
|
"typescript": "^5.0.4"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@phantom/api-key-stamper": "^0.1.
|
|
41
|
-
"@phantom/
|
|
40
|
+
"@phantom/api-key-stamper": "^0.1.3",
|
|
41
|
+
"@phantom/base64url": "^0.1.0",
|
|
42
|
+
"@phantom/client": "^0.1.6",
|
|
42
43
|
"@phantom/constants": "^0.0.2",
|
|
43
44
|
"@phantom/openapi-wallet-service": "^0.1.7",
|
|
44
|
-
"@phantom/parsers": "^0.0.
|
|
45
|
+
"@phantom/parsers": "^0.0.6",
|
|
46
|
+
"bs58": "^6.0.0"
|
|
45
47
|
},
|
|
46
48
|
"files": [
|
|
47
49
|
"dist"
|