@temple-digital-group/temple-canton-js 1.0.33 → 1.0.35

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
@@ -10,11 +10,11 @@ npm install @temple-digital-group/temple-canton-js
10
10
 
11
11
  ## Configuration
12
12
 
13
- There are three ways to use the SDK depending on your environment:
13
+ Call `initializeConfig()` before using any SDK functions. This is required in all environments.
14
14
 
15
- ### 1. Browser with Custom Validator
15
+ ### Custom Validator
16
16
 
17
- For browser apps connecting to your own validator. Requires `initializeConfig()` with your validator URLs and a pre-authenticated JWT token.
17
+ For apps connecting to your own validator (browser or server-side):
18
18
 
19
19
  ```javascript
20
20
  import { initializeConfig } from '@temple-digital-group/temple-canton-js';
@@ -23,10 +23,14 @@ initializeConfig({
23
23
  NETWORK: 'mainnet',
24
24
  VALIDATOR_API_URL: 'https://your-validator-url',
25
25
  VALIDATOR_SCAN_API_URL: 'https://your-scan-api-url',
26
- TEMPLE_PARTY_ID: 'your-temple-party-id',
27
- VALIDATOR_DSO_PARTY_ID: 'your-dso-party-id',
28
- JWT_TOKEN: 'your-jwt-token',
29
- VALIDATOR_USER_PARTY_ID: 'your-user-party-id'
26
+ VALIDATOR_USER_PARTY_ID: 'your-user-party-id',
27
+ JWT_TOKEN: 'your-jwt-token', // Browser: pass a pre-authenticated JWT
28
+ // — OR for server-side Auth0 —
29
+ // AUTH0_TOKEN_URL: 'https://your-auth0-domain/oauth/token',
30
+ // AUTH0_USER_ID: 'your-auth0-user-id',
31
+ // AUTH0_CLIENT_ID: 'your-client-id',
32
+ // AUTH0_CLIENT_SECRET: 'your-client-secret',
33
+ // AUTH0_AUDIENCE: 'your-audience',
30
34
  });
31
35
  ```
32
36
 
@@ -35,81 +39,43 @@ initializeConfig({
35
39
  | `NETWORK` | Yes | `mainnet`, `testnet`, or `localhost` |
36
40
  | `VALIDATOR_API_URL` | Yes | Base URL of the Canton validator ledger API |
37
41
  | `VALIDATOR_SCAN_API_URL` | Yes | Base URL of the Canton Scan API |
38
- | `TEMPLE_PARTY_ID` | Yes | Temple's party ID on the network |
39
- | `VALIDATOR_DSO_PARTY_ID` | Yes | The DSO (Decentralized Synchronizer Operator) party ID |
40
- | `JWT_TOKEN` | Yes | Pre-authenticated JWT token for ledger API calls |
41
42
  | `VALIDATOR_USER_PARTY_ID` | Yes | The user's party ID on the network |
43
+ | `JWT_TOKEN` | Yes* | Pre-authenticated JWT token for ledger API calls |
44
+ | `AUTH0_TOKEN_URL` | Yes* | Auth0 OAuth token endpoint |
45
+ | `AUTH0_CLIENT_ID` | Yes* | Auth0 application client ID |
46
+ | `AUTH0_CLIENT_SECRET` | Yes* | Auth0 application client secret |
47
+ | `AUTH0_AUDIENCE` | Yes* | Auth0 API audience identifier |
48
+ | `AUTH0_USER_ID` | Yes* | Auth0 user ID for the service account |
42
49
 
43
- ### 2. Browser with Wallet Provider
50
+ \* Provide either `JWT_TOKEN` (browser) or the `AUTH0_*` fields (server-side). The SDK fetches and caches JWT tokens automatically when Auth0 credentials are provided.
44
51
 
45
- For browser apps using a wallet (e.g., Loop Wallet). Requires `initializeConfig()` with base network config only. Use `returnCommand = true` to get the command back for the wallet to sign.
52
+ To update the JWT token later without re-initializing:
53
+
54
+ ```javascript
55
+ import { setJWTToken } from '@temple-digital-group/temple-canton-js';
56
+
57
+ setJWTToken(newToken);
58
+ ```
59
+
60
+ ### Wallet Provider
61
+
62
+ For apps using a wallet provider (e.g., Loop Wallet). Use `returnCommand = true` to get the command data back.
46
63
 
47
64
  ```javascript
48
65
  import { initializeConfig, createOrderProposal } from '@temple-digital-group/temple-canton-js';
49
66
 
50
67
  initializeConfig({
51
- NETWORK: 'mainnet',
52
- TEMPLE_PARTY_ID: 'your-temple-party-id',
53
- VALIDATOR_DSO_PARTY_ID: 'your-dso-party-id'
68
+ NETWORK: 'mainnet'
54
69
  });
55
70
 
56
- // returnCommand=true returns the command for the wallet to sign
57
71
  const command = await createOrderProposal(orderArgs, true, walletProvider);
58
- const result = await walletProvider.signAndSubmit(command);
59
72
  ```
60
73
 
61
74
  | Key | Required | Description |
62
75
  |-----|----------|-------------|
63
76
  | `NETWORK` | Yes | `mainnet`, `testnet`, or `localhost` |
64
- | `TEMPLE_PARTY_ID` | Yes | Temple's party ID on the network |
65
- | `VALIDATOR_DSO_PARTY_ID` | Yes | The DSO (Decentralized Synchronizer Operator) party ID |
66
-
67
- ### 3. Node.js / Server-Side
68
77
 
69
- For server-side applications. Uses environment variables directly no `initializeConfig()` call needed. Create a `.env` file:
70
-
71
- ```env
72
- NETWORK=mainnet
73
- VALIDATOR_API_URL=https://your-validator-url
74
- VALIDATOR_SCAN_API_URL=https://your-scan-api-url
75
- TEMPLE_PARTY_ID=your-temple-party-id
76
- VALIDATOR_DSO_PARTY_ID=your-dso-party-id
77
-
78
- AUTH0_TOKEN_URL=https://your-auth0-domain.auth0.com/oauth/token
79
- AUTH0_USER_ID=your-auth0-user-id
80
- AUTH0_CLIENT_ID=your-client-id
81
- AUTH0_CLIENT_SECRET=your-client-secret
82
- AUTH0_AUDIENCE=https://your-audience
83
- ```
84
-
85
- | Parameter | Required | Description |
86
- |-----------|----------|-------------|
87
- | `NETWORK` | Yes | `mainnet`, `testnet`, or `localhost` |
88
- | `VALIDATOR_API_URL` | Yes | Base URL of the Canton validator ledger API |
89
- | `VALIDATOR_SCAN_API_URL` | Yes | Base URL of the Canton Scan API |
90
- | `TEMPLE_PARTY_ID` | Yes | Temple's party ID on the network |
91
- | `VALIDATOR_DSO_PARTY_ID` | Yes | The DSO (Decentralized Synchronizer Operator) party ID |
92
- | `AUTH0_TOKEN_URL` | Yes | Auth0 OAuth token endpoint |
93
- | `AUTH0_CLIENT_ID` | Yes | Auth0 application client ID |
94
- | `AUTH0_CLIENT_SECRET` | Yes | Auth0 application client secret |
95
- | `AUTH0_AUDIENCE` | Yes | Auth0 API audience identifier |
96
- | `AUTH0_USER_ID` | Yes | Auth0 user ID for the service account |
97
-
98
- The SDK fetches and caches JWT tokens automatically via Auth0.
99
-
100
- You can also call `initializeConfig()` in Node.js to override specific environment variables at runtime. For example, if a frontend passes a JWT token to your server:
101
-
102
- ```javascript
103
- import { initializeConfig, getUserBalances } from '@temple-digital-group/temple-canton-js';
104
-
105
- // .env provides base config (NETWORK, VALIDATOR_API_URL, etc.)
106
- // Override with a token received from the frontend
107
- initializeConfig({ JWT_TOKEN: tokenFromFrontend });
108
-
109
- const balances = await getUserBalances(partyId);
110
- ```
111
-
112
- Runtime config values take precedence over environment variables.
78
+ > **Legacy:** Environment variables are still supported for backwards compatibility, but `initializeConfig()` is the recommended approach.
113
79
 
114
80
 
115
81
  ## Supported Instruments
@@ -196,6 +162,7 @@ if (counts.largestUnlocked >= requiredAmount) {
196
162
  | Function | Description |
197
163
  |----------|-------------|
198
164
  | `initializeConfig(config)` | Initialize the library with a runtime config object |
165
+ | `setJWTToken(token)` | Update the JWT token without re-initializing the config |
199
166
  | `getConfigValue(key)` | Get a config value from runtime config or environment |
200
167
 
201
168
  ### Authentication
@@ -265,7 +232,3 @@ These functions are synchronous and work in all environments (no ledger or provi
265
232
  | Function | Description |
266
233
  |----------|-------------|
267
234
  | ~~`cancelOrders(party, orderContractIds, assetType)`~~ | Batch cancel orders (deprecated — use the [Cancel Order](https://apidocs.templedigitalgroup.com/reference/cancelorder) or [Cancel All Orders](https://apidocs.templedigitalgroup.com/reference/cancelallorders) REST API instead) |
268
-
269
- ## License
270
-
271
- MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temple-digital-group/temple-canton-js",
3
- "version": "1.0.33",
3
+ "version": "1.0.35",
4
4
  "description": "JavaScript library for interacting with Temple Canton blockchain",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -15,6 +15,18 @@ export function initializeConfig(config) {
15
15
  appConfig = config;
16
16
  }
17
17
 
18
+ /**
19
+ * Update the JWT token without re-initializing the full config.
20
+ * Useful when refreshing tokens for custom validator connections.
21
+ * @param {string} token - The new JWT token
22
+ */
23
+ export function setJWTToken(token) {
24
+ if (!appConfig) {
25
+ appConfig = {};
26
+ }
27
+ appConfig.JWT_TOKEN = token;
28
+ }
29
+
18
30
  /**
19
31
  * Get a configuration value from:
20
32
  * 1. App-provided config (if initializeConfig was called)
@@ -45,6 +57,8 @@ export const NETWORK_MAINNET = "mainnet";
45
57
  // Network-specific contract values (Orchestrator & Featured App)
46
58
  const NETWORK_CONTRACTS = {
47
59
  [NETWORK_MAINNET]: {
60
+ TEMPLE_PARTY_ID: "temple-mainnet-1::1220f238bb79df3efbbac2ea964c3cd501003971a2cb59043e2dac50b06e85b8620f",
61
+ VALIDATOR_DSO_PARTY_ID: "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc",
48
62
  CONTRACT_ORCHESTRATOR_ID: "0026c99f5f6b8962cba69aee6392c65a2b5968a426ea18e971ec711259acd2e02eca12122024481221b69db9257de7875d2d74484a25a8b5795c77bc684442e812ff06ce81",
49
63
  TEMPLATE_ID_ORCHESTRATOR: "0110667c2e17ca40d2aa7396d3b40e228c770d203676b6950ac819de86cf6964:Temple.Order.Orchestrator:Orchestrator",
50
64
  DISCLOSURE_ORCHESTRATOR: "CgMyLjEStgMKRQAmyZ9fa4liy6aa7mOSxlorWWikJuoY6XHscRJZrNLgLsoSEiAkSBIhtp25JX3nh10tdEhKJai1eVx3vGhEQugS/wbOgRIRdGVtcGxlLW9yZGVyLWltcGwabQpAMDExMDY2N2MyZTE3Y2E0MGQyYWE3Mzk2ZDNiNDBlMjI4Yzc3MGQyMDM2NzZiNjk1MGFjODE5ZGU4NmNmNjk2NBIGVGVtcGxlEgVPcmRlchIMT3JjaGVzdHJhdG9yGgxPcmNoZXN0cmF0b3IiXmpcCloKWDpWdGVtcGxlLW1haW5uZXQtMTo6MTIyMGYyMzhiYjc5ZGYzZWZiYmFjMmVhOTY0YzNjZDUwMTAwMzk3MWEyY2I1OTA0M2UyZGFjNTBiMDZlODViODYyMGYqVnRlbXBsZS1tYWlubmV0LTE6OjEyMjBmMjM4YmI3OWRmM2VmYmJhYzJlYTk2NGMzY2Q1MDEwMDM5NzFhMmNiNTkwNDNlMmRhYzUwYjA2ZTg1Yjg2MjBmOeBCMhKJSAYAQioKJgokCAESIFBZFBJVc2L/ITJ2Y+Bz1lRHAVUnkiSiZJFuvzwlYwUyEB4=",
@@ -55,6 +69,8 @@ const NETWORK_CONTRACTS = {
55
69
  SYNCHRONIZER_FEATURED_APP: "global-domain::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc",
56
70
  },
57
71
  [NETWORK_TESTNET]: {
72
+ TEMPLE_PARTY_ID: "temple-testnet-1::12209b8dd6bb0fdc220f1a78ec54a10ece9e959e30d369c391b2f1efdb84f2b48262",
73
+ VALIDATOR_DSO_PARTY_ID: "DSO::1220f22a8b8f2d813c25b9a684dc4dd52b532a0174d8e73a13cdf2baabfff7518337",
58
74
  CONTRACT_ORCHESTRATOR_ID: "00ef7791cb51b45194791ba1d6d83f969878f17dfde50970daf9f8279c87417346ca1212202bb3d941b036cfcb8893b99d1ffd1bcc66e3999b5d67d4f6b77a728298f4fcdf",
59
75
  TEMPLATE_ID_ORCHESTRATOR: "0110667c2e17ca40d2aa7396d3b40e228c770d203676b6950ac819de86cf6964:Temple.Order.Orchestrator:Orchestrator",
60
76
  DISCLOSURE_ORCHESTRATOR: "CgMyLjEStgMKRQDvd5HLUbRRlHkbodbYP5aYePF9/eUJcNr5+Cech0FzRsoSEiArs9lBsDbPy4iTuZ0f/RvMZuOZm11n1Pa3enKCmPT83xIRdGVtcGxlLW9yZGVyLWltcGwabQpAMDExMDY2N2MyZTE3Y2E0MGQyYWE3Mzk2ZDNiNDBlMjI4Yzc3MGQyMDM2NzZiNjk1MGFjODE5ZGU4NmNmNjk2NBIGVGVtcGxlEgVPcmRlchIMT3JjaGVzdHJhdG9yGgxPcmNoZXN0cmF0b3IiXmpcCloKWDpWdGVtcGxlLXRlc3RuZXQtMTo6MTIyMDliOGRkNmJiMGZkYzIyMGYxYTc4ZWM1NGExMGVjZTllOTU5ZTMwZDM2OWMzOTFiMmYxZWZkYjg0ZjJiNDgyNjIqVnRlbXBsZS10ZXN0bmV0LTE6OjEyMjA5YjhkZDZiYjBmZGMyMjBmMWE3OGVjNTRhMTBlY2U5ZTk1OWUzMGQzNjljMzkxYjJmMWVmZGI4NGYyYjQ4MjYyOREf61eFSAYAQioKJgokCAESIIENK9R3ypVBYdnm6oV0J/a3GgdUNLbBFReq5znIYhc4EB4=",
@@ -85,9 +101,9 @@ const config = {
85
101
  // Validator connection settings
86
102
  get VALIDATOR_API_URL() { return getConfigValue("VALIDATOR_API_URL"); },
87
103
  get VALIDATOR_SCAN_API_URL() { return getConfigValue("VALIDATOR_SCAN_API_URL"); },
88
- get VALIDATOR_DSO_PARTY_ID() { return getConfigValue("VALIDATOR_DSO_PARTY_ID"); },
104
+ get VALIDATOR_DSO_PARTY_ID() { return getNetworkContract("VALIDATOR_DSO_PARTY_ID"); },
89
105
  get VALIDATOR_USER_PARTY_ID() { return getConfigValue("VALIDATOR_USER_PARTY_ID"); },
90
- get TEMPLE_PARTY_ID() { return getConfigValue("TEMPLE_PARTY_ID"); },
106
+ get TEMPLE_PARTY_ID() { return getNetworkContract("TEMPLE_PARTY_ID"); },
91
107
 
92
108
  // Auth0 settings
93
109
  get AUTH0_TOKEN_URL() { return getConfigValue("AUTH0_TOKEN_URL"); },
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Temple Digital Group
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.