@phantom/sdk-types 0.1.1

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 ADDED
@@ -0,0 +1,108 @@
1
+ # @phantom/sdk-types
2
+
3
+ Common TypeScript types and interfaces used across the Phantom Wallet SDK packages.
4
+
5
+ ## Overview
6
+
7
+ This package provides centralized type definitions that are shared across multiple Phantom SDK packages, ensuring consistency and reducing duplication.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @phantom/sdk-types
13
+ ```
14
+
15
+ ## Types
16
+
17
+ ### `Stamper`
18
+
19
+ Interface for creating X-Phantom-Stamp header values for API authentication.
20
+
21
+ ```typescript
22
+ interface Stamper {
23
+ stamp(params: {
24
+ data: Buffer;
25
+ type?: 'PKI';
26
+ idToken?: never;
27
+ salt?: never;
28
+ }): Promise<string>;
29
+ stamp(params: {
30
+ data: Buffer;
31
+ type: 'OIDC';
32
+ idToken: string;
33
+ salt: string;
34
+ }): Promise<string>;
35
+ }
36
+ ```
37
+
38
+ **Usage:**
39
+ ```typescript
40
+ import type { Stamper } from '@phantom/sdk-types';
41
+
42
+ class MyStamper implements Stamper {
43
+ async stamp(params: { data: Buffer; type?: 'PKI' }): Promise<string> {
44
+ // Implementation for PKI stamping
45
+ return 'stamp-value';
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### `StamperKeyInfo`
51
+
52
+ Key information structure returned by stampers.
53
+
54
+ ```typescript
55
+ interface StamperKeyInfo {
56
+ keyId: string;
57
+ publicKey: string;
58
+ }
59
+ ```
60
+
61
+ ### `StamperWithKeyManagement`
62
+
63
+ Extended stamper interface for stampers that manage their own cryptographic keys.
64
+
65
+ ```typescript
66
+ interface StamperWithKeyManagement extends Stamper {
67
+ init(): Promise<StamperKeyInfo>;
68
+ getKeyInfo(): StamperKeyInfo | null;
69
+ resetKeyPair?(): Promise<StamperKeyInfo>;
70
+ clear?(): Promise<void>;
71
+ }
72
+ ```
73
+
74
+ **Usage:**
75
+ ```typescript
76
+ import type { StamperWithKeyManagement } from '@phantom/sdk-types';
77
+
78
+ class MyKeyManagedStamper implements StamperWithKeyManagement {
79
+ async init(): Promise<StamperKeyInfo> {
80
+ // Initialize and return key info
81
+ return { keyId: 'key-id', publicKey: 'public-key' };
82
+ }
83
+
84
+ getKeyInfo(): StamperKeyInfo | null {
85
+ // Return current key info or null if not initialized
86
+ return { keyId: 'key-id', publicKey: 'public-key' };
87
+ }
88
+
89
+ async stamp(params: { data: Buffer; type?: 'PKI' }): Promise<string> {
90
+ // Implementation
91
+ return 'stamp-value';
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Package Usage
97
+
98
+ This package is used by:
99
+
100
+ - `@phantom/client` - For the base Stamper interface
101
+ - `@phantom/embedded-provider-core` - For StamperWithKeyManagement interface
102
+ - `@phantom/api-key-stamper` - Implements Stamper interface
103
+ - `@phantom/indexed-db-stamper` - Implements StamperWithKeyManagement interface
104
+ - `@phantom/react-native-sdk` - For embedded stampers
105
+
106
+ ## License
107
+
108
+ MIT
@@ -0,0 +1,31 @@
1
+ import { Buffer } from 'buffer';
2
+ import { Algorithm } from '@phantom/openapi-wallet-service';
3
+ export { Algorithm } from '@phantom/openapi-wallet-service';
4
+
5
+ interface Stamper {
6
+ stamp(params: {
7
+ data: Buffer;
8
+ type?: 'PKI';
9
+ idToken?: never;
10
+ salt?: never;
11
+ }): Promise<string>;
12
+ stamp(params: {
13
+ data: Buffer;
14
+ type: 'OIDC';
15
+ idToken: string;
16
+ salt: string;
17
+ }): Promise<string>;
18
+ algorithm: Algorithm;
19
+ }
20
+ interface StamperKeyInfo {
21
+ keyId: string;
22
+ publicKey: string;
23
+ }
24
+ interface StamperWithKeyManagement extends Stamper {
25
+ init(): Promise<StamperKeyInfo>;
26
+ getKeyInfo(): StamperKeyInfo | null;
27
+ resetKeyPair?(): Promise<StamperKeyInfo>;
28
+ clear?(): Promise<void>;
29
+ }
30
+
31
+ export { Stamper, StamperKeyInfo, StamperWithKeyManagement };
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Algorithm: () => import_openapi_wallet_service.Algorithm
24
+ });
25
+ module.exports = __toCommonJS(src_exports);
26
+ var import_openapi_wallet_service = require("@phantom/openapi-wallet-service");
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ Algorithm
30
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ // src/index.ts
2
+ import { Algorithm } from "@phantom/openapi-wallet-service";
3
+ export {
4
+ Algorithm
5
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@phantom/sdk-types",
3
+ "version": "0.1.1",
4
+ "description": "Common types for Phantom SDK packages",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "?pack-release": "When https://github.com/changesets/changesets/issues/432 has a solution we can remove this trick",
17
+ "pack-release": "rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
18
+ "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --external buffer",
19
+ "dev": "tsc --watch",
20
+ "clean": "rm -rf dist",
21
+ "test": "jest",
22
+ "test:watch": "jest --watch",
23
+ "lint": "tsc --noEmit && eslint --cache . --ext .ts,.tsx",
24
+ "check-types": "tsc --noEmit",
25
+ "prettier": "prettier --write \"src/**/*.{ts,tsx}\""
26
+ },
27
+ "devDependencies": {
28
+ "@types/jest": "^29.5.12",
29
+ "@types/node": "^20.11.0",
30
+ "eslint": "8.53.0",
31
+ "jest": "^29.7.0",
32
+ "prettier": "^3.5.2",
33
+ "rimraf": "^6.0.1",
34
+ "ts-jest": "^29.1.2",
35
+ "tsup": "^6.7.0",
36
+ "typescript": "^5.0.4"
37
+ },
38
+ "dependencies": {
39
+ "@phantom/openapi-wallet-service": "^0.1.7",
40
+ "buffer": "^6.0.3"
41
+ },
42
+ "files": [
43
+ "dist"
44
+ ],
45
+ "publishConfig": {
46
+ "directory": "_release/package"
47
+ }
48
+ }