@fairmint/canton-node-sdk 0.0.118 → 0.0.120
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 +5 -0
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts +4 -0
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js +4 -0
- package/build/src/clients/ledger-json-api/LedgerJsonApiClient.generated.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/authenticated-user/get.d.ts +2 -4
- package/build/src/clients/ledger-json-api/operations/v2/authenticated-user/get.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/authenticated-user/get.js +4 -5
- package/build/src/clients/ledger-json-api/operations/v2/authenticated-user/get.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/execute.d.ts +34 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/execute.d.ts.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/execute.js +13 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/execute.js.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/index.d.ts +2 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/index.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/index.js +2 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/index.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/prepare.d.ts +53 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/prepare.d.ts.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/prepare.js +13 -0
- package/build/src/clients/ledger-json-api/operations/v2/interactive-submission/prepare.js.map +1 -0
- package/build/src/clients/ledger-json-api/operations/v2/users/create-user.d.ts +0 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/create-user.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.d.ts +0 -2
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js +2 -4
- package/build/src/clients/ledger-json-api/operations/v2/users/get-user.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts +28 -7
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js +7 -4
- package/build/src/clients/ledger-json-api/operations/v2/users/grant-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts +0 -2
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js +2 -4
- package/build/src/clients/ledger-json-api/operations/v2/users/list-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.d.ts +0 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js +5 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/revoke-user-rights.js.map +1 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.d.ts +0 -1
- package/build/src/clients/ledger-json-api/operations/v2/users/update-user.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.d.ts +96 -0
- package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.js +107 -1
- package/build/src/clients/ledger-json-api/schemas/api/interactive-submission.js.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts +29 -14
- package/build/src/clients/ledger-json-api/schemas/operations/users.d.ts.map +1 -1
- package/build/src/clients/ledger-json-api/schemas/operations/users.js +9 -20
- package/build/src/clients/ledger-json-api/schemas/operations/users.js.map +1 -1
- package/build/src/clients/validator-api/ValidatorApiClient.generated.d.ts +6 -0
- package/build/src/clients/validator-api/ValidatorApiClient.generated.d.ts.map +1 -1
- package/build/src/clients/validator-api/ValidatorApiClient.generated.js +6 -0
- package/build/src/clients/validator-api/ValidatorApiClient.generated.js.map +1 -1
- package/build/src/clients/validator-api/operations/v0/admin/generate-external-party-topology.d.ts +22 -0
- package/build/src/clients/validator-api/operations/v0/admin/generate-external-party-topology.d.ts.map +1 -0
- package/build/src/clients/validator-api/operations/v0/admin/generate-external-party-topology.js +29 -0
- package/build/src/clients/validator-api/operations/v0/admin/generate-external-party-topology.js.map +1 -0
- package/build/src/clients/validator-api/operations/v0/admin/index.d.ts +2 -0
- package/build/src/clients/validator-api/operations/v0/admin/index.d.ts.map +1 -1
- package/build/src/clients/validator-api/operations/v0/admin/index.js +2 -0
- package/build/src/clients/validator-api/operations/v0/admin/index.js.map +1 -1
- package/build/src/clients/validator-api/operations/v0/admin/submit-external-party-topology.d.ts +25 -0
- package/build/src/clients/validator-api/operations/v0/admin/submit-external-party-topology.d.ts.map +1 -0
- package/build/src/clients/validator-api/operations/v0/admin/submit-external-party-topology.js +36 -0
- package/build/src/clients/validator-api/operations/v0/admin/submit-external-party-topology.js.map +1 -0
- package/build/src/clients/validator-api/operations/v0/get-validator-user-info.d.ts +17 -0
- package/build/src/clients/validator-api/operations/v0/get-validator-user-info.d.ts.map +1 -0
- package/build/src/clients/validator-api/operations/v0/get-validator-user-info.js +22 -0
- package/build/src/clients/validator-api/operations/v0/get-validator-user-info.js.map +1 -0
- package/build/src/clients/validator-api/operations/v0/index.d.ts +1 -0
- package/build/src/clients/validator-api/operations/v0/index.d.ts.map +1 -1
- package/build/src/clients/validator-api/operations/v0/index.js +1 -0
- package/build/src/clients/validator-api/operations/v0/index.js.map +1 -1
- package/build/src/core/logging/FileLogger.d.ts.map +1 -1
- package/build/src/core/logging/FileLogger.js +1 -1
- package/build/src/core/logging/FileLogger.js.map +1 -1
- package/build/src/utils/external-signing/allocate-external-party.d.ts +12 -0
- package/build/src/utils/external-signing/allocate-external-party.d.ts.map +1 -0
- package/build/src/utils/external-signing/allocate-external-party.js +13 -0
- package/build/src/utils/external-signing/allocate-external-party.js.map +1 -0
- package/build/src/utils/external-signing/create-external-party-privy.d.ts +74 -0
- package/build/src/utils/external-signing/create-external-party-privy.d.ts.map +1 -0
- package/build/src/utils/external-signing/create-external-party-privy.js +133 -0
- package/build/src/utils/external-signing/create-external-party-privy.js.map +1 -0
- package/build/src/utils/external-signing/create-external-party.d.ts +69 -0
- package/build/src/utils/external-signing/create-external-party.d.ts.map +1 -0
- package/build/src/utils/external-signing/create-external-party.js +81 -0
- package/build/src/utils/external-signing/create-external-party.js.map +1 -0
- package/build/src/utils/external-signing/execute-external-transaction.d.ts +15 -0
- package/build/src/utils/external-signing/execute-external-transaction.d.ts.map +1 -0
- package/build/src/utils/external-signing/execute-external-transaction.js +21 -0
- package/build/src/utils/external-signing/execute-external-transaction.js.map +1 -0
- package/build/src/utils/external-signing/generate-external-party.d.ts +15 -0
- package/build/src/utils/external-signing/generate-external-party.d.ts.map +1 -0
- package/build/src/utils/external-signing/generate-external-party.js +16 -0
- package/build/src/utils/external-signing/generate-external-party.js.map +1 -0
- package/build/src/utils/external-signing/index.d.ts +7 -0
- package/build/src/utils/external-signing/index.d.ts.map +1 -0
- package/build/src/utils/external-signing/index.js +23 -0
- package/build/src/utils/external-signing/index.js.map +1 -0
- package/build/src/utils/external-signing/prepare-external-transaction.d.ts +20 -0
- package/build/src/utils/external-signing/prepare-external-transaction.d.ts.map +1 -0
- package/build/src/utils/external-signing/prepare-external-transaction.js +24 -0
- package/build/src/utils/external-signing/prepare-external-transaction.js.map +1 -0
- package/build/src/utils/external-signing/privy-utils.d.ts +25 -0
- package/build/src/utils/external-signing/privy-utils.d.ts.map +1 -0
- package/build/src/utils/external-signing/privy-utils.js +56 -0
- package/build/src/utils/external-signing/privy-utils.js.map +1 -0
- package/build/src/utils/external-signing/stellar-utils.d.ts +48 -0
- package/build/src/utils/external-signing/stellar-utils.d.ts.map +1 -0
- package/build/src/utils/external-signing/stellar-utils.js +72 -0
- package/build/src/utils/external-signing/stellar-utils.js.map +1 -0
- package/build/src/utils/index.d.ts +2 -0
- package/build/src/utils/index.d.ts.map +1 -1
- package/build/src/utils/index.js +2 -0
- package/build/src/utils/index.js.map +1 -1
- package/build/src/utils/privy/client.d.ts +36 -0
- package/build/src/utils/privy/client.d.ts.map +1 -0
- package/build/src/utils/privy/client.js +56 -0
- package/build/src/utils/privy/client.js.map +1 -0
- package/build/src/utils/privy/createWallet.d.ts +30 -0
- package/build/src/utils/privy/createWallet.d.ts.map +1 -0
- package/build/src/utils/privy/createWallet.js +62 -0
- package/build/src/utils/privy/createWallet.js.map +1 -0
- package/build/src/utils/privy/getWallet.d.ts +25 -0
- package/build/src/utils/privy/getWallet.d.ts.map +1 -0
- package/build/src/utils/privy/getWallet.js +50 -0
- package/build/src/utils/privy/getWallet.js.map +1 -0
- package/build/src/utils/privy/index.d.ts +6 -0
- package/build/src/utils/privy/index.d.ts.map +1 -0
- package/build/src/utils/privy/index.js +22 -0
- package/build/src/utils/privy/index.js.map +1 -0
- package/build/src/utils/privy/signData.d.ts +34 -0
- package/build/src/utils/privy/signData.d.ts.map +1 -0
- package/build/src/utils/privy/signData.js +62 -0
- package/build/src/utils/privy/signData.js.map +1 -0
- package/build/src/utils/privy/types.d.ts +45 -0
- package/build/src/utils/privy/types.d.ts.map +1 -0
- package/build/src/utils/privy/types.js +4 -0
- package/build/src/utils/privy/types.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PrivyClient } from '@privy-io/node';
|
|
2
|
+
import type { CreateStellarWalletOptions, StellarWallet } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Stellar wallet using Privy
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createPrivyClient, createStellarWallet } from '@fairmint/canton-node-sdk';
|
|
9
|
+
*
|
|
10
|
+
* const privy = createPrivyClient({
|
|
11
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
12
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Create unlinked wallet
|
|
16
|
+
* const wallet = await createStellarWallet(privy);
|
|
17
|
+
*
|
|
18
|
+
* // Create wallet linked to a user
|
|
19
|
+
* const userWallet = await createStellarWallet(privy, {
|
|
20
|
+
* userId: 'did:privy:...'
|
|
21
|
+
* });
|
|
22
|
+
* ```;
|
|
23
|
+
*
|
|
24
|
+
* @param privyClient - Configured Privy client instance
|
|
25
|
+
* @param options - Optional configuration for wallet creation
|
|
26
|
+
* @returns Promise resolving to the created Stellar wallet information
|
|
27
|
+
* @throws Error if wallet creation fails or userId format is invalid
|
|
28
|
+
*/
|
|
29
|
+
export declare function createStellarWallet(privyClient: PrivyClient, options?: CreateStellarWalletOptions): Promise<StellarWallet>;
|
|
30
|
+
//# sourceMappingURL=createWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWallet.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/createWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,aAAa,CAAC,CAsCxB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStellarWallet = createStellarWallet;
|
|
4
|
+
const stellar_base_1 = require("@stellar/stellar-base");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new Stellar wallet using Privy
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createPrivyClient, createStellarWallet } from '@fairmint/canton-node-sdk';
|
|
11
|
+
*
|
|
12
|
+
* const privy = createPrivyClient({
|
|
13
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
14
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Create unlinked wallet
|
|
18
|
+
* const wallet = await createStellarWallet(privy);
|
|
19
|
+
*
|
|
20
|
+
* // Create wallet linked to a user
|
|
21
|
+
* const userWallet = await createStellarWallet(privy, {
|
|
22
|
+
* userId: 'did:privy:...'
|
|
23
|
+
* });
|
|
24
|
+
* ```;
|
|
25
|
+
*
|
|
26
|
+
* @param privyClient - Configured Privy client instance
|
|
27
|
+
* @param options - Optional configuration for wallet creation
|
|
28
|
+
* @returns Promise resolving to the created Stellar wallet information
|
|
29
|
+
* @throws Error if wallet creation fails or userId format is invalid
|
|
30
|
+
*/
|
|
31
|
+
async function createStellarWallet(privyClient, options) {
|
|
32
|
+
// Validate userId format if provided
|
|
33
|
+
if (options?.userId && !options.userId.startsWith('did:privy:')) {
|
|
34
|
+
throw new Error(`Invalid user ID format. User ID must start with "did:privy:", got: ${options.userId}`);
|
|
35
|
+
}
|
|
36
|
+
// Create wallet request
|
|
37
|
+
const createRequest = {
|
|
38
|
+
chain_type: 'stellar',
|
|
39
|
+
};
|
|
40
|
+
if (options?.userId) {
|
|
41
|
+
createRequest.owner = { user_id: options.userId };
|
|
42
|
+
}
|
|
43
|
+
// Create the wallet
|
|
44
|
+
const privyWallet = await privyClient.wallets().create(createRequest);
|
|
45
|
+
// Decode Stellar address to get base64 public key
|
|
46
|
+
const rawPublicKey = stellar_base_1.StrKey.decodeEd25519PublicKey(privyWallet.address);
|
|
47
|
+
const publicKeyBase64 = Buffer.from(rawPublicKey).toString('base64');
|
|
48
|
+
// Safely access owner property that may not be in type definitions
|
|
49
|
+
const { owner } = privyWallet;
|
|
50
|
+
const result = {
|
|
51
|
+
id: privyWallet.id,
|
|
52
|
+
address: privyWallet.address,
|
|
53
|
+
chain_type: 'stellar',
|
|
54
|
+
publicKeyBase64,
|
|
55
|
+
};
|
|
56
|
+
// Only include owner if it exists (for exactOptionalPropertyTypes compliance)
|
|
57
|
+
if (owner) {
|
|
58
|
+
result.owner = owner;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=createWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWallet.js","sourceRoot":"","sources":["../../../../src/utils/privy/createWallet.ts"],"names":[],"mappings":";;AA8BA,kDAyCC;AAtED,wDAA+C;AAG/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,KAAK,UAAU,mBAAmB,CACvC,WAAwB,EACxB,OAAoC;IAEpC,qCAAqC;IACrC,IAAI,OAAO,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,sEAAsE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1G,CAAC;IAED,wBAAwB;IACxB,MAAM,aAAa,GAA2D;QAC5E,UAAU,EAAE,SAAS;KACtB,CAAC;IAEF,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,aAAa,CAAC,KAAK,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IACpD,CAAC;IAED,oBAAoB;IACpB,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEtE,kDAAkD;IAClD,MAAM,YAAY,GAAG,qBAAM,CAAC,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAErE,mEAAmE;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,WAA8C,CAAC;IAEjE,MAAM,MAAM,GAAkB;QAC5B,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,UAAU,EAAE,SAAS;QACrB,eAAe;KAChB,CAAC;IAEF,8EAA8E;IAC9E,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PrivyClient } from '@privy-io/node';
|
|
2
|
+
import type { StellarWallet } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves an existing Stellar wallet from Privy by wallet ID
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createPrivyClient, getStellarWallet } from '@fairmint/canton-node-sdk';
|
|
9
|
+
*
|
|
10
|
+
* const privy = createPrivyClient({
|
|
11
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
12
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const wallet = await getStellarWallet(privy, 'wallet-id-here');
|
|
16
|
+
* console.log('Wallet address:', wallet.address);
|
|
17
|
+
* ```;
|
|
18
|
+
*
|
|
19
|
+
* @param privyClient - Configured Privy client instance
|
|
20
|
+
* @param walletId - The wallet ID to retrieve
|
|
21
|
+
* @returns Promise resolving to the Stellar wallet information
|
|
22
|
+
* @throws Error if wallet is not found or is not a Stellar wallet
|
|
23
|
+
*/
|
|
24
|
+
export declare function getStellarWallet(privyClient: PrivyClient, walletId: string): Promise<StellarWallet>;
|
|
25
|
+
//# sourceMappingURL=getWallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWallet.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/getWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA6BzG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStellarWallet = getStellarWallet;
|
|
4
|
+
const stellar_base_1 = require("@stellar/stellar-base");
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves an existing Stellar wallet from Privy by wallet ID
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createPrivyClient, getStellarWallet } from '@fairmint/canton-node-sdk';
|
|
11
|
+
*
|
|
12
|
+
* const privy = createPrivyClient({
|
|
13
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
14
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* const wallet = await getStellarWallet(privy, 'wallet-id-here');
|
|
18
|
+
* console.log('Wallet address:', wallet.address);
|
|
19
|
+
* ```;
|
|
20
|
+
*
|
|
21
|
+
* @param privyClient - Configured Privy client instance
|
|
22
|
+
* @param walletId - The wallet ID to retrieve
|
|
23
|
+
* @returns Promise resolving to the Stellar wallet information
|
|
24
|
+
* @throws Error if wallet is not found or is not a Stellar wallet
|
|
25
|
+
*/
|
|
26
|
+
async function getStellarWallet(privyClient, walletId) {
|
|
27
|
+
// Get the wallet from Privy
|
|
28
|
+
const privyWallet = await privyClient.wallets().get(walletId);
|
|
29
|
+
// Verify it's a Stellar wallet
|
|
30
|
+
if (privyWallet.chain_type !== 'stellar') {
|
|
31
|
+
throw new Error(`Wallet ${walletId} is not a Stellar wallet. Found chain_type: ${privyWallet.chain_type}`);
|
|
32
|
+
}
|
|
33
|
+
// Decode Stellar address to get base64 public key
|
|
34
|
+
const rawPublicKey = stellar_base_1.StrKey.decodeEd25519PublicKey(privyWallet.address);
|
|
35
|
+
const publicKeyBase64 = Buffer.from(rawPublicKey).toString('base64');
|
|
36
|
+
// Safely access owner property that may not be in type definitions
|
|
37
|
+
const { owner } = privyWallet;
|
|
38
|
+
const result = {
|
|
39
|
+
id: privyWallet.id,
|
|
40
|
+
address: privyWallet.address,
|
|
41
|
+
chain_type: 'stellar',
|
|
42
|
+
publicKeyBase64,
|
|
43
|
+
};
|
|
44
|
+
// Only include owner if it exists (for exactOptionalPropertyTypes compliance)
|
|
45
|
+
if (owner) {
|
|
46
|
+
result.owner = owner;
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWallet.js","sourceRoot":"","sources":["../../../../src/utils/privy/getWallet.ts"],"names":[],"mappings":";;AAyBA,4CA6BC;AArDD,wDAA+C;AAG/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,KAAK,UAAU,gBAAgB,CAAC,WAAwB,EAAE,QAAgB;IAC/E,4BAA4B;IAC5B,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE9D,+BAA+B;IAC/B,IAAI,WAAW,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,+CAA+C,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;IAC7G,CAAC;IAED,kDAAkD;IAClD,MAAM,YAAY,GAAG,qBAAM,CAAC,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAErE,mEAAmE;IACnE,MAAM,EAAE,KAAK,EAAE,GAAG,WAA8C,CAAC;IAEjE,MAAM,MAAM,GAAkB;QAC5B,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,UAAU,EAAE,SAAS;QACrB,eAAe;KAChB,CAAC;IAEF,8EAA8E;IAC9E,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./createWallet"), exports);
|
|
19
|
+
__exportStar(require("./getWallet"), exports);
|
|
20
|
+
__exportStar(require("./signData"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/privy/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,8CAA4B;AAC5B,6CAA2B;AAC3B,0CAAwB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { PrivyClient } from '@privy-io/node';
|
|
2
|
+
import type { SignOptions, SignResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Signs data using a Stellar wallet managed by Privy
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { createPrivyClient, signWithWallet } from '@fairmint/canton-node-sdk';
|
|
9
|
+
*
|
|
10
|
+
* const privy = createPrivyClient({
|
|
11
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
12
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Sign a hex string
|
|
16
|
+
* const result = await signWithWallet(privy, {
|
|
17
|
+
* walletId: 'wallet-id-here',
|
|
18
|
+
* data: 'deadbeef'
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Sign a Buffer
|
|
22
|
+
* const bufferResult = await signWithWallet(privy, {
|
|
23
|
+
* walletId: 'wallet-id-here',
|
|
24
|
+
* data: Buffer.from('test message')
|
|
25
|
+
* });
|
|
26
|
+
* ```;
|
|
27
|
+
*
|
|
28
|
+
* @param privyClient - Configured Privy client instance
|
|
29
|
+
* @param options - Signing options including wallet ID and data
|
|
30
|
+
* @returns Promise resolving to the signature result
|
|
31
|
+
* @throws Error if signing fails
|
|
32
|
+
*/
|
|
33
|
+
export declare function signWithWallet(privyClient: PrivyClient, options: SignOptions): Promise<SignResult>;
|
|
34
|
+
//# sourceMappingURL=signData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signData.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/signData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CA+BxG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signWithWallet = signWithWallet;
|
|
4
|
+
/**
|
|
5
|
+
* Signs data using a Stellar wallet managed by Privy
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { createPrivyClient, signWithWallet } from '@fairmint/canton-node-sdk';
|
|
10
|
+
*
|
|
11
|
+
* const privy = createPrivyClient({
|
|
12
|
+
* appId: process.env.PRIVY_APP_ID!,
|
|
13
|
+
* appSecret: process.env.PRIVY_APP_SECRET!
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Sign a hex string
|
|
17
|
+
* const result = await signWithWallet(privy, {
|
|
18
|
+
* walletId: 'wallet-id-here',
|
|
19
|
+
* data: 'deadbeef'
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Sign a Buffer
|
|
23
|
+
* const bufferResult = await signWithWallet(privy, {
|
|
24
|
+
* walletId: 'wallet-id-here',
|
|
25
|
+
* data: Buffer.from('test message')
|
|
26
|
+
* });
|
|
27
|
+
* ```;
|
|
28
|
+
*
|
|
29
|
+
* @param privyClient - Configured Privy client instance
|
|
30
|
+
* @param options - Signing options including wallet ID and data
|
|
31
|
+
* @returns Promise resolving to the signature result
|
|
32
|
+
* @throws Error if signing fails
|
|
33
|
+
*/
|
|
34
|
+
async function signWithWallet(privyClient, options) {
|
|
35
|
+
const { walletId, data } = options;
|
|
36
|
+
// Convert data to hex if it's a Buffer
|
|
37
|
+
let hexData;
|
|
38
|
+
if (Buffer.isBuffer(data)) {
|
|
39
|
+
hexData = data.toString('hex');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Remove 0x prefix if present
|
|
43
|
+
hexData = data.startsWith('0x') ? data.slice(2) : data;
|
|
44
|
+
}
|
|
45
|
+
// Validate hex string
|
|
46
|
+
if (!/^[0-9a-fA-F]*$/.test(hexData)) {
|
|
47
|
+
throw new Error(`Invalid hex data: ${hexData}`);
|
|
48
|
+
}
|
|
49
|
+
// Sign using Privy's rawSign API
|
|
50
|
+
const { signature, encoding } = await privyClient.wallets().rawSign(walletId, {
|
|
51
|
+
params: { hash: `0x${hexData}` },
|
|
52
|
+
});
|
|
53
|
+
// Remove 0x prefix and convert to base64
|
|
54
|
+
const signatureHex = signature.startsWith('0x') ? signature.slice(2) : signature;
|
|
55
|
+
const signatureBase64 = Buffer.from(signatureHex, 'hex').toString('base64');
|
|
56
|
+
return {
|
|
57
|
+
signature,
|
|
58
|
+
encoding,
|
|
59
|
+
signatureBase64,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=signData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signData.js","sourceRoot":"","sources":["../../../../src/utils/privy/signData.ts"],"names":[],"mappings":";;AAiCA,wCA+BC;AA7DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACI,KAAK,UAAU,cAAc,CAAC,WAAwB,EAAE,OAAoB;IACjF,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEnC,uCAAuC;IACvC,IAAI,OAAe,CAAC;IACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,8BAA8B;QAC9B,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;IAED,sBAAsB;IACtB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,iCAAiC;IACjC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC5E,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,EAAE;KACjC,CAAC,CAAC;IAEH,yCAAyC;IACzC,MAAM,YAAY,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE5E,OAAO;QACL,SAAS;QACT,QAAQ;QACR,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Privy wallet types and interfaces */
|
|
2
|
+
/** Options for creating a Privy client */
|
|
3
|
+
export interface PrivyClientOptions {
|
|
4
|
+
/** Privy App ID from environment variables or provided directly */
|
|
5
|
+
appId: string;
|
|
6
|
+
/** Privy App Secret from environment variables or provided directly */
|
|
7
|
+
appSecret: string;
|
|
8
|
+
}
|
|
9
|
+
/** Options for creating a Stellar wallet */
|
|
10
|
+
export interface CreateStellarWalletOptions {
|
|
11
|
+
/** Optional user ID to link the wallet to (format: did:privy:...) */
|
|
12
|
+
userId?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Stellar wallet information returned from Privy */
|
|
15
|
+
export interface StellarWallet {
|
|
16
|
+
/** Wallet ID (used for signing operations) */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Stellar public address */
|
|
19
|
+
address: string;
|
|
20
|
+
/** Chain type (always 'stellar' for Stellar wallets) */
|
|
21
|
+
chain_type: 'stellar';
|
|
22
|
+
/** Owner information if wallet is linked to a user */
|
|
23
|
+
owner?: {
|
|
24
|
+
user_id: string;
|
|
25
|
+
};
|
|
26
|
+
/** Base64 encoded public key (derived from address) */
|
|
27
|
+
publicKeyBase64: string;
|
|
28
|
+
}
|
|
29
|
+
/** Options for signing data with a Stellar wallet */
|
|
30
|
+
export interface SignOptions {
|
|
31
|
+
/** Wallet ID to use for signing */
|
|
32
|
+
walletId: string;
|
|
33
|
+
/** Data to sign (will be hex encoded if not already) */
|
|
34
|
+
data: string | Buffer;
|
|
35
|
+
}
|
|
36
|
+
/** Result of a signing operation */
|
|
37
|
+
export interface SignResult {
|
|
38
|
+
/** Signature in hex format (with 0x prefix) */
|
|
39
|
+
signature: string;
|
|
40
|
+
/** Signature encoding format */
|
|
41
|
+
encoding: string;
|
|
42
|
+
/** Signature in base64 format */
|
|
43
|
+
signatureBase64: string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/types.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,4CAA4C;AAC5C,MAAM,WAAW,0BAA0B;IACzC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,UAAU,EAAE,SAAS,CAAC;IACtB,sDAAsD;IACtD,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,oCAAoC;AACpC,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/privy/types.ts"],"names":[],"mappings":";AAAA,wCAAwC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fairmint/canton-node-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.120",
|
|
4
4
|
"description": "Canton Node SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"canton",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"format": "prettier --check .",
|
|
37
37
|
"format:fix": "prettier --write .",
|
|
38
38
|
"generate:openapi-types": "tsx scripts/generate-openapi-types.ts",
|
|
39
|
+
"grant-user-rights": "tsx scripts/grant-user-rights.ts",
|
|
39
40
|
"lint": "eslint .",
|
|
40
41
|
"lint:fix": "eslint . --fix",
|
|
41
42
|
"lint:npm": "npmPkgJsonLint . --fix",
|
|
@@ -55,11 +56,15 @@
|
|
|
55
56
|
"test:watch": "jest --watch"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
59
|
+
"@canton-network/wallet-sdk": "0.15.0",
|
|
60
|
+
"@privy-io/node": "^0.3.0",
|
|
61
|
+
"@stellar/stellar-base": "^14.0.1",
|
|
58
62
|
"axios": "1.12.2",
|
|
59
63
|
"dotenv": "17.2.3",
|
|
60
64
|
"glob": "11.0.3",
|
|
61
65
|
"openapi-fetch": "0.15.0",
|
|
62
66
|
"openapi-typescript": "7.10.1",
|
|
67
|
+
"pino": "^9.0.0",
|
|
63
68
|
"ws": "8.18.3",
|
|
64
69
|
"zod": "4.1.12"
|
|
65
70
|
},
|