@fairmint/canton-node-sdk 0.0.118 → 0.0.119

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.
@@ -3,5 +3,6 @@ export * from './contracts';
3
3
  export * from './mining';
4
4
  export * from './parsers';
5
5
  export * from './party';
6
+ export * from './privy';
6
7
  export * from './transactions';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -19,5 +19,6 @@ __exportStar(require("./contracts"), exports);
19
19
  __exportStar(require("./mining"), exports);
20
20
  __exportStar(require("./parsers"), exports);
21
21
  __exportStar(require("./party"), exports);
22
+ __exportStar(require("./privy"), exports);
22
23
  __exportStar(require("./transactions"), exports);
23
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,0CAAwB;AACxB,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,iDAA+B"}
@@ -0,0 +1,36 @@
1
+ import { PrivyClient } from '@privy-io/node';
2
+ import type { PrivyClientOptions } from './types';
3
+ /**
4
+ * Creates a Privy client instance for wallet operations
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createPrivyClient } 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
+ *
16
+ * @param options - Configuration options for the Privy client
17
+ * @returns Configured PrivyClient instance
18
+ * @throws Error if appId or appSecret are missing
19
+ */
20
+ export declare function createPrivyClient(options: PrivyClientOptions): PrivyClient;
21
+ /**
22
+ * Creates a Privy client from environment variables
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { createPrivyClientFromEnv } from '@fairmint/canton-node-sdk';
27
+ *
28
+ * // Requires PRIVY_APP_ID and PRIVY_APP_SECRET in environment
29
+ * const privy = createPrivyClientFromEnv();
30
+ * ```;
31
+ *
32
+ * @returns Configured PrivyClient instance
33
+ * @throws Error if PRIVY_APP_ID or PRIVY_APP_SECRET are not set
34
+ */
35
+ export declare function createPrivyClientFromEnv(): PrivyClient;
36
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/utils/privy/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAiB1E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,IAAI,WAAW,CAKtD"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPrivyClient = createPrivyClient;
4
+ exports.createPrivyClientFromEnv = createPrivyClientFromEnv;
5
+ const node_1 = require("@privy-io/node");
6
+ /**
7
+ * Creates a Privy client instance for wallet operations
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { createPrivyClient } from '@fairmint/canton-node-sdk';
12
+ *
13
+ * const privy = createPrivyClient({
14
+ * appId: process.env.PRIVY_APP_ID!,
15
+ * appSecret: process.env.PRIVY_APP_SECRET!
16
+ * });
17
+ * ```;
18
+ *
19
+ * @param options - Configuration options for the Privy client
20
+ * @returns Configured PrivyClient instance
21
+ * @throws Error if appId or appSecret are missing
22
+ */
23
+ function createPrivyClient(options) {
24
+ const { appId, appSecret } = options;
25
+ if (!appId) {
26
+ throw new Error('Privy App ID is required. Set PRIVY_APP_ID environment variable or provide appId option.');
27
+ }
28
+ if (!appSecret) {
29
+ throw new Error('Privy App Secret is required. Set PRIVY_APP_SECRET environment variable or provide appSecret option.');
30
+ }
31
+ return new node_1.PrivyClient({
32
+ appId,
33
+ appSecret,
34
+ });
35
+ }
36
+ /**
37
+ * Creates a Privy client from environment variables
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { createPrivyClientFromEnv } from '@fairmint/canton-node-sdk';
42
+ *
43
+ * // Requires PRIVY_APP_ID and PRIVY_APP_SECRET in environment
44
+ * const privy = createPrivyClientFromEnv();
45
+ * ```;
46
+ *
47
+ * @returns Configured PrivyClient instance
48
+ * @throws Error if PRIVY_APP_ID or PRIVY_APP_SECRET are not set
49
+ */
50
+ function createPrivyClientFromEnv() {
51
+ return createPrivyClient({
52
+ appId: process.env['PRIVY_APP_ID'] ?? '',
53
+ appSecret: process.env['PRIVY_APP_SECRET'] ?? '',
54
+ });
55
+ }
56
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/utils/privy/client.ts"],"names":[],"mappings":";;AAoBA,8CAiBC;AAgBD,4DAKC;AA1DD,yCAA6C;AAG7C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAErC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAC;IAC9G,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,kBAAW,CAAC;QACrB,KAAK;QACL,SAAS;KACV,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,wBAAwB;IACtC,OAAO,iBAAiB,CAAC;QACvB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE;QACxC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE;KACjD,CAAC,CAAC;AACL,CAAC"}
@@ -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,6 @@
1
+ export * from './client';
2
+ export * from './createWallet';
3
+ export * from './getWallet';
4
+ export * from './signData';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -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,4 @@
1
+ "use strict";
2
+ /** Privy wallet types and interfaces */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=types.js.map
@@ -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.118",
3
+ "version": "0.0.119",
4
4
  "description": "Canton Node SDK",
5
5
  "keywords": [
6
6
  "canton",
@@ -55,6 +55,8 @@
55
55
  "test:watch": "jest --watch"
56
56
  },
57
57
  "dependencies": {
58
+ "@privy-io/node": "^0.3.0",
59
+ "@stellar/stellar-base": "^14.0.1",
58
60
  "axios": "1.12.2",
59
61
  "dotenv": "17.2.3",
60
62
  "glob": "11.0.3",