@openfort/openfort-node 0.6.78 → 0.7.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 +6 -0
- package/Makefile +75 -0
- package/README.md +174 -65
- package/biome.json +34 -4
- package/dist/index.d.mts +8871 -14863
- package/dist/index.d.ts +8871 -14863
- package/dist/index.js +4978 -24180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4677 -23904
- package/dist/index.mjs.map +1 -1
- package/examples/.env.example +16 -0
- package/examples/README.md +154 -0
- package/examples/contracts/createContract.ts +25 -0
- package/examples/contracts/listContracts.ts +18 -0
- package/examples/contracts/readContract.ts +29 -0
- package/examples/evm/accounts/createAccount.ts +18 -0
- package/examples/evm/accounts/exportAccount.ts +39 -0
- package/examples/evm/accounts/getAccount.ts +30 -0
- package/examples/evm/accounts/importAccount.ts +31 -0
- package/examples/evm/accounts/listAccounts.ts +32 -0
- package/examples/evm/signing/signHash.ts +28 -0
- package/examples/evm/signing/signMessage.ts +32 -0
- package/examples/evm/signing/signTransaction.ts +42 -0
- package/examples/evm/signing/signTypedData.ts +71 -0
- package/examples/exchange/createSwap.ts +49 -0
- package/examples/exchange/quoteSwap.ts +34 -0
- package/examples/iam/deleteUser.ts +22 -0
- package/examples/iam/getSession.ts +30 -0
- package/examples/iam/getUser.ts +32 -0
- package/examples/iam/listUsers.ts +18 -0
- package/examples/iam/pregenerateUser.ts +33 -0
- package/examples/package.json +31 -0
- package/examples/pnpm-lock.yaml +1231 -0
- package/examples/policies/createPolicy.ts +25 -0
- package/examples/policies/createPolicyRule.ts +43 -0
- package/examples/policies/disableEnablePolicy.ts +29 -0
- package/examples/policies/getPolicy.ts +30 -0
- package/examples/policies/listPolicies.ts +17 -0
- package/examples/policies/listPolicyRules.ts +37 -0
- package/examples/policies/updatePolicy.ts +29 -0
- package/examples/solana/accounts/createAccount.ts +18 -0
- package/examples/solana/accounts/exportAccount.ts +29 -0
- package/examples/solana/accounts/getAccount.ts +24 -0
- package/examples/solana/accounts/importAccount.ts +28 -0
- package/examples/solana/accounts/listAccounts.ts +32 -0
- package/examples/solana/signing/signMessage.ts +22 -0
- package/examples/solana/signing/signTransaction.ts +41 -0
- package/examples/transactions/createTransactionIntent.ts +49 -0
- package/examples/transactions/estimateGas.ts +52 -0
- package/examples/transactions/getTransactionIntent.ts +54 -0
- package/examples/transactions/listTransactionIntents.ts +31 -0
- package/examples/tsconfig.json +15 -0
- package/examples/webhook/index.ts +43 -0
- package/openapi-auth.json +6526 -0
- package/openapi.json +20425 -0
- package/orval.config.ts +41 -0
- package/package.json +22 -12
- package/pnpm-workspace.yaml +2 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +20 -0
- package/updateGeneratedCode.sh +0 -8
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Usage: npx tsx iam/getSession.ts <access_token>
|
|
2
|
+
|
|
3
|
+
import Openfort from "@openfort/openfort-node";
|
|
4
|
+
import "dotenv/config";
|
|
5
|
+
|
|
6
|
+
const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
7
|
+
basePath: process.env.OPENFORT_BASE_URL,
|
|
8
|
+
publishableKey: process.env.OPENFORT_PUBLISHABLE_KEY,
|
|
9
|
+
debugging: true,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const accessToken = process.argv[2];
|
|
13
|
+
|
|
14
|
+
if (!accessToken) {
|
|
15
|
+
console.error("Usage: npx tsx iam/getSession.ts <access_token>");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Get session info using the user's access token
|
|
20
|
+
const response = await openfort.iam.getSession({ accessToken });
|
|
21
|
+
if (response === null) {
|
|
22
|
+
console.error("Invalid token");
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
console.log(response)
|
|
26
|
+
console.log("Session verified:");
|
|
27
|
+
console.log(" User ID:", response.user.id);
|
|
28
|
+
console.log(" User Email:", response.user.email);
|
|
29
|
+
console.log(" Session ID:", response.session.id);
|
|
30
|
+
console.log(" Expires At:", response.session.expiresAt);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Usage: npx tsx iam/getUser.ts <user_id>
|
|
2
|
+
|
|
3
|
+
import Openfort from "@openfort/openfort-node";
|
|
4
|
+
import "dotenv/config";
|
|
5
|
+
|
|
6
|
+
const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
7
|
+
basePath: process.env.OPENFORT_BASE_URL,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const userId = process.argv[2];
|
|
11
|
+
|
|
12
|
+
if (!userId) {
|
|
13
|
+
console.error("Usage: npx tsx iam/getUser.ts <user_id>");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Get a specific user by ID
|
|
18
|
+
const user = await openfort.iam.users.get(userId);
|
|
19
|
+
|
|
20
|
+
console.log("User details:");
|
|
21
|
+
console.log(" ID:", user.id);
|
|
22
|
+
console.log(" Name:", user.name);
|
|
23
|
+
console.log(" Email:", user.email ?? "N/A");
|
|
24
|
+
console.log(" Email Verified:", user.emailVerified);
|
|
25
|
+
console.log(" Created:", new Date(user.createdAt * 1000).toISOString());
|
|
26
|
+
console.log(" Linked Accounts:");
|
|
27
|
+
for (const account of user.linkedAccounts) {
|
|
28
|
+
console.log(` - Provider: ${account.provider}`);
|
|
29
|
+
if (account.accountId) {
|
|
30
|
+
console.log(` Account ID: ${account.accountId}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Usage: npx tsx iam/listUsers.ts
|
|
2
|
+
|
|
3
|
+
import Openfort from "@openfort/openfort-node";
|
|
4
|
+
import "dotenv/config";
|
|
5
|
+
|
|
6
|
+
const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
7
|
+
basePath: process.env.OPENFORT_BASE_URL,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// List all authenticated users
|
|
11
|
+
const result = await openfort.iam.users.list({ limit: 10 });
|
|
12
|
+
|
|
13
|
+
console.log(`Found ${result.total} users:`);
|
|
14
|
+
for (const user of result.data) {
|
|
15
|
+
console.log(` - ${user.id}`);
|
|
16
|
+
console.log(` Created: ${new Date(user.createdAt * 1000).toISOString()}`);
|
|
17
|
+
console.log(` Linked Accounts: ${user.linkedAccounts.length}`);
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Usage: npx tsx iam/pregenerateUser.ts
|
|
2
|
+
|
|
3
|
+
import Openfort, { ShieldAuthProvider } from "@openfort/openfort-node";
|
|
4
|
+
import "dotenv/config";
|
|
5
|
+
|
|
6
|
+
const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
7
|
+
basePath: process.env.OPENFORT_BASE_URL,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Pre-generate a user with an embedded wallet
|
|
11
|
+
// This creates the user and wallet before they authenticate
|
|
12
|
+
const result = await openfort.iam.users.pregenerate(
|
|
13
|
+
{
|
|
14
|
+
email: "jaume+1@openfort.xyz",
|
|
15
|
+
accountType: "Externally Owned Account"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
shieldApiKey: process.env.SHIELD_API_KEY!,
|
|
19
|
+
shieldApiSecret: process.env.SHIELD_API_SECRET!,
|
|
20
|
+
shieldAuthProvider: ShieldAuthProvider.OPENFORT,
|
|
21
|
+
encryptionShare: process.env.SHIELD_ENCRYPTION_SHARE!,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
console.log("Pre-generated user with embedded wallet:");
|
|
26
|
+
console.log(" Account ID:", result.id);
|
|
27
|
+
console.log(" User ID:", result.user);
|
|
28
|
+
console.log(" Address:", result.address);
|
|
29
|
+
console.log(" Owner Address:", result.ownerAddress);
|
|
30
|
+
console.log(" Account Type:", result.accountType);
|
|
31
|
+
console.log(" Chain ID:", result.chainId);
|
|
32
|
+
console.log(" Chain Type:", result.chainType);
|
|
33
|
+
console.log(" Created:", new Date(result.createdAt * 1000).toISOString());
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfort/openfort-node-examples",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Examples for the Openfort Node SDK",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build:sdk": "pnpm --dir .. build",
|
|
9
|
+
"preinstall": "pnpm --dir .. install",
|
|
10
|
+
"setup": "pnpm install && pnpm build:sdk",
|
|
11
|
+
"example": "tsx",
|
|
12
|
+
"format": "biome format --write",
|
|
13
|
+
"lint": "biome lint",
|
|
14
|
+
"check": "biome check --write"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "Openfort",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@biomejs/biome": "^2.2.4",
|
|
21
|
+
"tsx": "^4.19.0",
|
|
22
|
+
"typescript": "^5.1.6"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@openfort/openfort-node": "link:..",
|
|
26
|
+
"@types/express": "^4.17.17",
|
|
27
|
+
"dotenv": "^16.3.1",
|
|
28
|
+
"express": "^4.19.2",
|
|
29
|
+
"viem": "^2.21.0"
|
|
30
|
+
}
|
|
31
|
+
}
|