@dynamic-labs/waas-ton 4.51.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/.eslintrc.json +33 -0
- package/jest.config.ts +29 -0
- package/package.json +28 -0
- package/project.json +47 -0
- package/rollup.config.cjs +7 -0
- package/src/index.ts +18 -0
- package/src/types/index.ts +39 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/logger/logger.spec.ts +7 -0
- package/src/utils/logger/logger.ts +6 -0
- package/test/mocks/browserWalletClientMock.ts +38 -0
- package/test/setupAfterEnv.config.ts +7 -0
- package/tsconfig.json +23 -0
- package/tsconfig.lib.json +10 -0
- package/tsconfig.spec.json +14 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../.eslintrc.json"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {
|
|
8
|
+
"import/no-namespace": "off",
|
|
9
|
+
"no-restricted-syntax": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
"selector": "MemberExpression[object.name='window'][property.name='location']",
|
|
13
|
+
"message": "Use PlatformService from @dynamic-labs/utils package instead of directly accessing window.location."
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
|
|
20
|
+
"rules": {
|
|
21
|
+
"no-restricted-syntax": "off"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"files": ["*.ts", "*.tsx"],
|
|
26
|
+
"rules": {}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"files": ["*.js", "*.jsx"],
|
|
30
|
+
"rules": {}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* eslint-disable sort-keys */
|
|
3
|
+
|
|
4
|
+
const esModules = [
|
|
5
|
+
'@dynamic-labs-wallet/forward-mpc-client',
|
|
6
|
+
'@dynamic-labs-wallet/forward-mpc-shared',
|
|
7
|
+
'@noble/.*',
|
|
8
|
+
'@evervault/wasm-attestation-bindings',
|
|
9
|
+
].join('|');
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
displayName: 'waas-ton',
|
|
13
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
14
|
+
preset: '../../jest.preset.js',
|
|
15
|
+
resetMocks: false,
|
|
16
|
+
transform: {
|
|
17
|
+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
|
|
18
|
+
'node_modules/@onflow': 'ts-jest',
|
|
19
|
+
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/react/babel'] }],
|
|
20
|
+
},
|
|
21
|
+
transformIgnorePatterns: [`node_modules/(?!(${esModules}|@simplewebauthn)/)`],
|
|
22
|
+
moduleNameMapper: {
|
|
23
|
+
'@dynamic-labs-wallet/browser-wallet-client':
|
|
24
|
+
'<rootDir>/test/mocks/browserWalletClientMock.ts',
|
|
25
|
+
},
|
|
26
|
+
maxWorkers: '2',
|
|
27
|
+
workerIdleMemoryLimit: '1.25gb',
|
|
28
|
+
setupFilesAfterEnv: ['./test/setupAfterEnv.config.ts'],
|
|
29
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/waas-ton",
|
|
3
|
+
"version": "4.51.0",
|
|
4
|
+
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
|
+
"author": "Dynamic Labs, Inc.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./src/index.cjs",
|
|
8
|
+
"module": "./src/index.js",
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://www.dynamic.xyz/",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.51.1",
|
|
22
|
+
"@dynamic-labs/logger": "4.51.1",
|
|
23
|
+
"@dynamic-labs/sdk-api-core": "0.0.843",
|
|
24
|
+
"@ton/core": "0.62.0",
|
|
25
|
+
"@ton/crypto": "3.3.0",
|
|
26
|
+
"@ton/ton": "16.0.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "waas-ton",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/waas-ton/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"post-build": {},
|
|
8
|
+
"build": {
|
|
9
|
+
"executor": "@nrwl/rollup:rollup",
|
|
10
|
+
"outputs": ["{options.outputPath}"],
|
|
11
|
+
"dependsOn": ["^build"],
|
|
12
|
+
"options": {
|
|
13
|
+
"outputPath": "dist/packages/waas-ton",
|
|
14
|
+
"entryFile": "packages/waas-ton/src/index.ts",
|
|
15
|
+
"tsConfig": "packages/waas-ton/tsconfig.lib.json",
|
|
16
|
+
"project": "packages/waas-ton/package.json",
|
|
17
|
+
"rollupConfig": "packages/waas-ton/rollup.config.cjs",
|
|
18
|
+
"buildableProjectDepsInPackageJsonType": "dependencies",
|
|
19
|
+
"updateBuildableProjectDepsInPackageJson": true,
|
|
20
|
+
"compiler": "tsc",
|
|
21
|
+
"format": ["esm", "cjs"]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"lint": {
|
|
25
|
+
"executor": "@nrwl/linter:eslint",
|
|
26
|
+
"outputs": ["{options.outputFile}"],
|
|
27
|
+
"options": {
|
|
28
|
+
"lintFilePatterns": ["packages/waas-ton/**/*.ts"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"test": {
|
|
32
|
+
"executor": "@nrwl/jest:jest",
|
|
33
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
34
|
+
"options": {
|
|
35
|
+
"jestConfig": "packages/waas-ton/jest.config.ts",
|
|
36
|
+
"passWithNoTests": true
|
|
37
|
+
},
|
|
38
|
+
"configurations": {
|
|
39
|
+
"ci": {
|
|
40
|
+
"ci": true,
|
|
41
|
+
"codeCoverage": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"tags": []
|
|
47
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { toNano } from '@ton/core';
|
|
2
|
+
import { TonClient } from '@ton/ton';
|
|
3
|
+
import { mnemonicToWalletKey } from '@ton/crypto';
|
|
4
|
+
|
|
5
|
+
import { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
7
|
+
|
|
8
|
+
import { version as packageVersion } from '../package.json';
|
|
9
|
+
|
|
10
|
+
assertPackageVersion('@dynamic-labs/waas-ton', packageVersion);
|
|
11
|
+
|
|
12
|
+
export { TonClient, toNano, mnemonicToWalletKey, type SignMessageContext };
|
|
13
|
+
|
|
14
|
+
export type {
|
|
15
|
+
TonConnectDomain,
|
|
16
|
+
TonConnectProof,
|
|
17
|
+
TonTransactionData,
|
|
18
|
+
} from './types';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain information for TON Connect protocol
|
|
3
|
+
*/
|
|
4
|
+
export interface TonConnectDomain {
|
|
5
|
+
/** Length of domain value in bytes */
|
|
6
|
+
lengthBytes: number;
|
|
7
|
+
/** Domain value (e.g., example.com) */
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Complete TON Connect proof object
|
|
13
|
+
*/
|
|
14
|
+
export interface TonConnectProof {
|
|
15
|
+
/** Wallet address string */
|
|
16
|
+
address: string;
|
|
17
|
+
/** Domain information */
|
|
18
|
+
domain: TonConnectDomain;
|
|
19
|
+
/** Unix timestamp in seconds */
|
|
20
|
+
timestamp: number;
|
|
21
|
+
/** Payload string */
|
|
22
|
+
payload: string;
|
|
23
|
+
/** Signature as base64 string */
|
|
24
|
+
signature: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generic transaction data that can be used for any TON transaction type
|
|
29
|
+
*/
|
|
30
|
+
export interface TonTransactionData {
|
|
31
|
+
/** Sender wallet address */
|
|
32
|
+
address: string;
|
|
33
|
+
/** Current wallet seqno */
|
|
34
|
+
seqno: number;
|
|
35
|
+
/** Base64-encoded message body (the transaction to be signed) */
|
|
36
|
+
messageBody: string;
|
|
37
|
+
/** Transaction timeout in seconds */
|
|
38
|
+
timeout: number;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './logger/logger';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const createWalletAccountMock = jest.fn();
|
|
2
|
+
export const exportClientKeysharesMock = jest.fn();
|
|
3
|
+
export const getWalletMock = jest.fn();
|
|
4
|
+
export const signMessageMock = jest.fn();
|
|
5
|
+
export const exportPrivateKeyMock = jest.fn();
|
|
6
|
+
export const importPrivateKeyMock = jest.fn();
|
|
7
|
+
export const backupKeySharesToGoogleDriveMock = jest.fn();
|
|
8
|
+
export const delegateKeySharesMock = jest.fn();
|
|
9
|
+
export const refreshWalletAccountSharesMock = jest.fn();
|
|
10
|
+
export const updatePasswordMock = jest.fn();
|
|
11
|
+
export const signRawMessageMock = jest.fn();
|
|
12
|
+
|
|
13
|
+
export const AuthMode = {
|
|
14
|
+
HEADER: 'header',
|
|
15
|
+
COOKIE: 'cookie',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class DynamicWalletClient {
|
|
19
|
+
initialize = jest.fn();
|
|
20
|
+
createWalletAccount = createWalletAccountMock;
|
|
21
|
+
exportClientKeyshares = exportClientKeysharesMock;
|
|
22
|
+
getWallet = getWalletMock;
|
|
23
|
+
signMessage = signMessageMock;
|
|
24
|
+
exportPrivateKey = exportPrivateKeyMock;
|
|
25
|
+
importPrivateKey = importPrivateKeyMock;
|
|
26
|
+
backupKeySharesToGoogleDrive = backupKeySharesToGoogleDriveMock;
|
|
27
|
+
delegateKeyShares = delegateKeySharesMock;
|
|
28
|
+
refreshWalletAccountShares = refreshWalletAccountSharesMock;
|
|
29
|
+
updatePassword = updatePasswordMock;
|
|
30
|
+
signRawMessage = signRawMessageMock;
|
|
31
|
+
chainName = 'TON';
|
|
32
|
+
cleanup = jest.fn();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const ThresholdSignatureScheme = {
|
|
36
|
+
TWO_OF_TWO: 'TWO_OF_TWO',
|
|
37
|
+
TWO_OF_THREE: 'TWO_OF_THREE',
|
|
38
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"esModuleInterop": false,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitOverride": true,
|
|
9
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"noFallthroughCasesInSwitch": true
|
|
12
|
+
},
|
|
13
|
+
"files": [],
|
|
14
|
+
"include": [],
|
|
15
|
+
"references": [
|
|
16
|
+
{
|
|
17
|
+
"path": "./tsconfig.lib.json"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "./tsconfig.spec.json"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"jest.config.ts",
|
|
10
|
+
"src/**/*.test.ts",
|
|
11
|
+
"src/**/*.spec.ts",
|
|
12
|
+
"src/**/*.d.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|