@tinycloudlabs/web-sdk 0.1.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.
Files changed (36) hide show
  1. package/README.md +151 -0
  2. package/dist/index.d.ts +13 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.LICENSE.txt +21 -0
  6. package/dist/modules/Storage/TinyCloudStorage.d.ts +181 -0
  7. package/dist/modules/Storage/TinyCloudStorage.d.ts.map +1 -0
  8. package/dist/modules/Storage/index.d.ts +3 -0
  9. package/dist/modules/Storage/index.d.ts.map +1 -0
  10. package/dist/modules/Storage/interfaces.d.ts +119 -0
  11. package/dist/modules/Storage/interfaces.d.ts.map +1 -0
  12. package/dist/modules/Storage/tinycloud/authenticator.d.ts +12 -0
  13. package/dist/modules/Storage/tinycloud/authenticator.d.ts.map +1 -0
  14. package/dist/modules/Storage/tinycloud/capabilities.d.ts +25 -0
  15. package/dist/modules/Storage/tinycloud/capabilities.d.ts.map +1 -0
  16. package/dist/modules/Storage/tinycloud/index.d.ts +6 -0
  17. package/dist/modules/Storage/tinycloud/index.d.ts.map +1 -0
  18. package/dist/modules/Storage/tinycloud/kv.d.ts +18 -0
  19. package/dist/modules/Storage/tinycloud/kv.d.ts.map +1 -0
  20. package/dist/modules/Storage/tinycloud/module.d.ts +10 -0
  21. package/dist/modules/Storage/tinycloud/module.d.ts.map +1 -0
  22. package/dist/modules/Storage/tinycloud/orbit.d.ts +167 -0
  23. package/dist/modules/Storage/tinycloud/orbit.d.ts.map +1 -0
  24. package/dist/modules/Storage/tinycloud/tinycloud.d.ts +43 -0
  25. package/dist/modules/Storage/tinycloud/tinycloud.d.ts.map +1 -0
  26. package/dist/modules/Storage/tinycloud/types.d.ts +64 -0
  27. package/dist/modules/Storage/tinycloud/types.d.ts.map +1 -0
  28. package/dist/modules/Storage/tinycloud/walletProvider.d.ts +19 -0
  29. package/dist/modules/Storage/tinycloud/walletProvider.d.ts.map +1 -0
  30. package/dist/modules/UserAuthorization.d.ts +166 -0
  31. package/dist/modules/UserAuthorization.d.ts.map +1 -0
  32. package/dist/modules/index.d.ts +3 -0
  33. package/dist/modules/index.d.ts.map +1 -0
  34. package/dist/tcw.d.ts +95 -0
  35. package/dist/tcw.d.ts.map +1 -0
  36. package/package.json +73 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tinycloud.d.ts","sourceRoot":"","sources":["../../../../src/modules/Storage/tinycloud/tinycloud.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,eAAe,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,uCAAuC;AACvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,0DAA0D;AAC1D,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAiB;IAE/B;;;OAGG;gBACS,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB;IAO5D;;;;;;;;;;;;;;OAcG;IACG,KAAK,CACT,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM,GAClC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;CAyBxC;AAED,eAAO,MAAM,MAAM,QACZ,MAAM,UACH;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,sBACW,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Configuration object for starting a TinyCloud session.
3
+ */
4
+ export type SessionConfig = {
5
+ /** Actions that the session key will be permitted to perform, organized by service and path */
6
+ actions: {
7
+ [service: string]: {
8
+ [key: string]: string[];
9
+ };
10
+ };
11
+ /** Ethereum address. */
12
+ address: string;
13
+ /** Chain ID. */
14
+ chainId: number;
15
+ /** Domain of the webpage. */
16
+ domain: string;
17
+ /** Current time for SIWE message. */
18
+ issuedAt: string;
19
+ /** The orbit that is the target resource of the delegation. */
20
+ orbitId: string;
21
+ /** The earliest time that the session will be valid from. */
22
+ notBefore?: string;
23
+ /** The latest time that the session will be valid until. */
24
+ expirationTime: string;
25
+ /** Optional parent delegations to inherit and attenuate */
26
+ parents?: string[];
27
+ /** Optional jwk to delegate to */
28
+ jwk?: object;
29
+ };
30
+ /**
31
+ * A TinyCloud session.
32
+ */
33
+ export type Session = {
34
+ /** The delegation from the user to the session key. */
35
+ delegationHeader: {
36
+ Authorization: string;
37
+ };
38
+ /** The delegation reference from the user to the session key. */
39
+ delegationCid: string;
40
+ /** The session key. */
41
+ jwk: object;
42
+ /** The orbit that the session key is permitted to perform actions against. */
43
+ orbitId: string;
44
+ /** The verification method of the session key. */
45
+ verificationMethod: string;
46
+ };
47
+ /**
48
+ * Configuration object for generating a Orbit Host Delegation SIWE message.
49
+ */
50
+ export type HostConfig = {
51
+ /** Ethereum address. */
52
+ address: string;
53
+ /** Chain ID. */
54
+ chainId: number;
55
+ /** Domain of the webpage. */
56
+ domain: string;
57
+ /** Current time for SIWE message. */
58
+ issuedAt: string;
59
+ /** The orbit that is the target resource of the delegation. */
60
+ orbitId: string;
61
+ /** The peer that is the target/invoker in the delegation. */
62
+ peerId: string;
63
+ };
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/modules/Storage/tinycloud/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,+FAA+F;IAC/F,OAAO,EAAE;QAAE,CAAC,OAAO,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IAC5D,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,uDAAuD;IACvD,gBAAgB,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,iEAAiE;IACjE,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /** An array of bytes represented as an array of integers. */
2
+ export type Bytes = ArrayLike<number>;
3
+ /** A common interface that a wallet must implement to be compatible with this SDK.
4
+ *
5
+ * Wallet representations implement APIs that can be reduced to this subset of functionality. The
6
+ * {@link https://docs.ethers.io/v5/api/signer/#Signer | Signer} from ethers is fully compatible
7
+ * with this interface.
8
+ */
9
+ export interface WalletProvider {
10
+ /** Returns the account address. */
11
+ getAddress(): Promise<string>;
12
+ /** Returns the chain ID that this wallet is connected to. */
13
+ getChainId(): Promise<number>;
14
+ /** Performs a `personal_sign` on the message and returns the signature as a hex string of the
15
+ * format `"0x<65 bytes>"`.
16
+ */
17
+ signMessage(message: Bytes | string): Promise<string>;
18
+ }
19
+ //# sourceMappingURL=walletProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletProvider.d.ts","sourceRoot":"","sources":["../../../../src/modules/Storage/tinycloud/walletProvider.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,6DAA6D;IAC7D,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD"}
@@ -0,0 +1,166 @@
1
+ import { providers, Signer } from 'ethers';
2
+ import { tcwSession } from '@tinycloudlabs/web-sdk-wasm';
3
+ import { AxiosInstance } from 'axios';
4
+ import { TCWEnsData } from '@tinycloudlabs/web-core';
5
+ import { TCWClientSession, TCWClientConfig, ITCWConnected, TCWExtension } from '@tinycloudlabs/web-core/client';
6
+ /** UserAuthorization Module
7
+ *
8
+ * Handles the capabilities that a user can provide a app, specifically
9
+ * authentication and authorization. This resource handles all key and
10
+ * signing capabilities including:
11
+ * - ethereum provider, wallet connection, SIWE message creation and signing
12
+ * - session key management
13
+ * - creates, manages, and handles session data
14
+ * - manages/provides capabilities
15
+ */
16
+ interface IUserAuthorization {
17
+ provider: providers.Web3Provider;
18
+ session?: TCWClientSession;
19
+ extend: (extension: TCWExtension) => void;
20
+ connect(): Promise<any>;
21
+ signIn(): Promise<any>;
22
+ /**
23
+ * ENS data supported by TCW.
24
+ * @param address - User address.
25
+ * @param resolveEnsOpts - Options to resolve ENS.
26
+ * @returns Object containing ENS data.
27
+ */
28
+ resolveEns(
29
+ /** User address */
30
+ address: string): Promise<TCWEnsData>;
31
+ address(): string | undefined;
32
+ chainId(): number | undefined;
33
+ /**
34
+ * Signs a message using the private key of the connected address.
35
+ * @returns signature;
36
+ */
37
+ signMessage(message: string): Promise<string>;
38
+ getSigner(): Signer;
39
+ signOut(): Promise<any>;
40
+ }
41
+ declare class UserAuthorizationInit {
42
+ private config?;
43
+ /** Extensions for the TCWClientSession. */
44
+ private extensions;
45
+ /** The session representation (once signed in). */
46
+ session?: TCWClientSession;
47
+ constructor(config?: TCWClientConfig);
48
+ /** Extend the session with an TCW compatible extension. */
49
+ extend(extension: TCWExtension): void;
50
+ /**
51
+ * Connect to the signing account using the configured provider.
52
+ * @returns UserAuthorizationConnected instance.
53
+ */
54
+ connect(): Promise<UserAuthorizationConnected>;
55
+ }
56
+ /** An intermediate TCW state: connected, but not signed-in. */
57
+ declare class UserAuthorizationConnected implements ITCWConnected {
58
+ /** Instance of TCWSessionManager */
59
+ builder: tcwSession.TCWSessionManager;
60
+ /** TCWConfig object. */
61
+ config: TCWClientConfig;
62
+ /** Enabled extensions. */
63
+ extensions: TCWExtension[];
64
+ /** EthersJS provider. */
65
+ provider: providers.Web3Provider;
66
+ /**
67
+ * Promise that is initialized on construction of this class to run the "afterConnect" methods
68
+ * of the extensions.
69
+ */
70
+ afterConnectHooksPromise: Promise<void>;
71
+ /** Verifies if extension is enabled. */
72
+ isExtensionEnabled: (namespace: string) => boolean;
73
+ /** Axios instance. */
74
+ api?: AxiosInstance;
75
+ /** Ethereum Provider */
76
+ constructor(
77
+ /** Instance of TCWSessionManager */
78
+ builder: tcwSession.TCWSessionManager,
79
+ /** TCWConfig object. */
80
+ config: TCWClientConfig,
81
+ /** Enabled extensions. */
82
+ extensions: TCWExtension[],
83
+ /** EthersJS provider. */
84
+ provider: providers.Web3Provider);
85
+ /** Applies the "afterConnect" methods and the delegated capabilities of the extensions. */
86
+ applyExtensions(): Promise<void>;
87
+ /**
88
+ * Applies the "afterSignIn" methods of the extensions.
89
+ * @param session - TCWClientSession object.
90
+ */
91
+ afterSignIn(session: TCWClientSession): Promise<void>;
92
+ /**
93
+ * Requests the user to sign in.
94
+ * Generates the SIWE message for this session, requests the configured
95
+ * Signer to sign the message, calls the "afterSignIn" methods of the
96
+ * extensions.
97
+ * @returns Promise with the TCWClientSession object.
98
+ */
99
+ signIn(): Promise<TCWClientSession>;
100
+ /**
101
+ * Requests the user to sign out.
102
+ * @param session - TCWClientSession object.
103
+ */
104
+ signOut(session: TCWClientSession): Promise<void>;
105
+ }
106
+ declare class UserAuthorization implements IUserAuthorization {
107
+ private _config;
108
+ /** The Ethereum provider */
109
+ provider: providers.Web3Provider;
110
+ /** The session representation (once signed in). */
111
+ session?: TCWClientSession;
112
+ /** TCWClientSession builder. */
113
+ private init;
114
+ /** Current connection of TCW */
115
+ private connection?;
116
+ /** The TCWClientConfig object. */
117
+ private config;
118
+ constructor(_config?: TCWClientConfig);
119
+ /**
120
+ * Extends TCW with a functions that are called after connecting and signing in.
121
+ */
122
+ extend(extension: TCWExtension): void;
123
+ connect(): Promise<void>;
124
+ signIn(): Promise<TCWClientSession>;
125
+ /**
126
+ * ENS data supported by TCW.
127
+ * @param address - User address.
128
+ * @param resolveEnsOpts - Options to resolve ENS.
129
+ * @returns Object containing ENS data.
130
+ */
131
+ resolveEns(
132
+ /** User address */
133
+ address: string): Promise<TCWEnsData>;
134
+ /**
135
+ * Invalidates user's session.
136
+ */
137
+ signOut(): Promise<void>;
138
+ /**
139
+ * Gets the address that is connected and signed in.
140
+ * @returns Address.
141
+ */
142
+ address: () => string | undefined;
143
+ /**
144
+ * Get the chainId that the address is connected and signed in on.
145
+ * @returns chainId.
146
+ */
147
+ chainId: () => number | undefined;
148
+ /**
149
+ * Signs a message using the private key of the connected address.
150
+ * @returns signature;
151
+ */
152
+ signMessage(message: string): Promise<string>;
153
+ /**
154
+ * Gets the provider that is connected and signed in.
155
+ * @returns Provider.
156
+ */
157
+ getProvider(): providers.Web3Provider | undefined;
158
+ /**
159
+ * Returns the signer of the connected address.
160
+ * @returns ethers.Signer
161
+ * @see https://docs.ethers.io/v5/api/signer/#Signer
162
+ */
163
+ getSigner(): Signer;
164
+ }
165
+ export { IUserAuthorization, UserAuthorization, UserAuthorizationInit, UserAuthorizationConnected, };
166
+ //# sourceMappingURL=UserAuthorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserAuthorization.d.ts","sourceRoot":"","sources":["../../src/modules/UserAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAe,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EACL,UAAU,EAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACb,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;GASG;AACH,UAAU,kBAAkB;IAE1B,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC;IACjC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAG3B,MAAM,EAAE,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB;;;;;OAKG;IACH,UAAU;IACR,mBAAmB;IACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,IAAI,M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-0,0 +1,3 @@
1
+ export * from './UserAuthorization';
2
+ export * from './Storage';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
package/dist/tcw.d.ts ADDED
@@ -0,0 +1,95 @@
1
+ import { TCWRPCProviders, TCWEnsData } from '@tinycloudlabs/web-core';
2
+ import { IUserAuthorization, TinyCloudStorage } from './modules';
3
+ import { TCWClientConfig, TCWClientSession, TCWExtension } from '@tinycloudlabs/web-core/client';
4
+ import type { providers, Signer } from 'ethers';
5
+ declare global {
6
+ interface Window {
7
+ ethereum?: any;
8
+ }
9
+ }
10
+ /**
11
+ * Configuration for managing TCW Modules
12
+ */
13
+ interface TCWModuleConfig {
14
+ storage?: boolean | {
15
+ [key: string]: any;
16
+ };
17
+ }
18
+ interface TCWConfig extends TCWClientConfig {
19
+ modules?: TCWModuleConfig;
20
+ }
21
+ /** TCW: TinyCloud Web SDK
22
+ *
23
+ * An SDK for building user-controlled web apps.
24
+ */
25
+ export declare class TinyCloudWeb {
26
+ private config;
27
+ /** The Ethereum provider */
28
+ provider: providers.Web3Provider;
29
+ /** Supported RPC Providers */
30
+ static RPCProviders: typeof TCWRPCProviders;
31
+ /** UserAuthorization Module
32
+ *
33
+ * Handles the capabilities that a user can provide a app, specifically
34
+ * authentication and authorization. This resource handles all key and
35
+ * signing capabilities including:
36
+ * - ethereum provider, wallet connection, SIWE message creation and signing
37
+ * - session key management
38
+ * - creates, manages, and handles session data
39
+ * - manages/provides capabilities
40
+ */
41
+ userAuthorization: IUserAuthorization;
42
+ /** Storage Module */
43
+ storage: TinyCloudStorage;
44
+ constructor(config?: TCWConfig);
45
+ /**
46
+ * Extends TCW with a functions that are called after connecting and signing in.
47
+ */
48
+ extend(extension: TCWExtension): void;
49
+ /**
50
+ * Request the user to sign in, and start the session.
51
+ * @returns Object containing information about the session
52
+ */
53
+ signIn: () => Promise<TCWClientSession>;
54
+ /**
55
+ * Invalidates user's session.
56
+ */
57
+ signOut: () => Promise<void>;
58
+ /**
59
+ * ENS data supported by TCW.
60
+ * @param address - User address.
61
+ * @param resolveEnsOpts - Options to resolve ENS.
62
+ * @returns Object containing ENS data.
63
+ */
64
+ resolveEns(
65
+ /** User address */
66
+ address: string): Promise<TCWEnsData>;
67
+ /**
68
+ * Gets the session representation (once signed in).
69
+ * @returns Address.
70
+ */
71
+ session: () => TCWClientSession | undefined;
72
+ /**
73
+ * Gets the address that is connected and signed in.
74
+ * @returns Address.
75
+ */
76
+ address: () => string | undefined;
77
+ /**
78
+ * Get the chainId that the address is connected and signed in on.
79
+ * @returns chainId.
80
+ */
81
+ chainId: () => number | undefined;
82
+ /**
83
+ * Gets the provider that is connected and signed in.
84
+ * @returns Provider.
85
+ */
86
+ getProvider(): providers.Web3Provider | undefined;
87
+ /**
88
+ * Returns the signer of the connected address.
89
+ * @returns ethers.Signer
90
+ * @see https://docs.ethers.io/v5/api/signer/#Signer
91
+ */
92
+ getSigner(): Signer;
93
+ }
94
+ export {};
95
+ //# sourceMappingURL=tcw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tcw.d.ts","sourceRoot":"","sources":["../src/tcw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,YAAY,EACb,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB;CACF;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,OAAO,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC5C;AAGD,UAAU,SAAU,SAAQ,eAAe;IACzC,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAUD;;;GAGG;AACH,qBAAa,YAAY;IAsBX,OAAO,CAAC,MAAM;IArB1B,4BAA4B;IACrB,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC;IAExC,8BAA8B;IAC9B,OAAc,YAAY,yBAAmB;IAE7C;;;;;;;;;OASG;IACI,iBAAiB,EAAE,kBAAkB,CAAC;IAE7C,qBAAqB;IACd,OAAO,EAAE,gBAAgB,CAAC;gBAEb,MAAM,GAAE,SAA8B;IA2B1D;;OAEG;IACI,MAAM,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;IAI5C;;;OAGG;IACI,MAAM,QAAa,OAAO,CAAC,gBAAgB,CAAC,CAEjD;IAEF;;OAEG;IACI,OAAO,QAAa,OAAO,CAAC,IAAI,CAAC,CAEtC;IAEF;;;;;OAKG;IACU,UAAU;IACrB,mBAAmB;IACnB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC;IAItB;;;OAGG;IACI,OAAO,EAAE,MAAM,gBAAgB,GAAG,SAAS,CACjB;IAEjC;;;OAGG;IACI,OAAO,EAAE,MAAM,MAAM,GAAG,SAAS,CACL;IAEnC;;;OAGG;IACI,OAAO,EAAE,MAAM,MAAM,GAAG,SAAS,CACL;IAEnC;;;OAGG;IACI,WAAW,IAAI,SAAS,CAAC,YAAY,GAAG,SAAS;IAIxD;;;;OAIG;IACI,SAAS,IAAI,MAAM;CAG3B"}
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@tinycloudlabs/web-sdk",
3
+ "version": "0.1.0",
4
+ "description": "A set of tools and utilities to help you build your app with TinyCloud.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "ssh://git@github.com:TinyCloudLabs/web-sdk.git"
10
+ },
11
+ "type": "commonjs",
12
+ "author": "TinyCloud, Inc.",
13
+ "license": "Apache-2.0 OR MIT",
14
+ "scripts": {
15
+ "build": "webpack --mode production",
16
+ "watch": "webpack --watch",
17
+ "doc": "bun run doc:extractor && bun run doc:documenter",
18
+ "doc:extractor": "api-extractor run --local --diagnostics",
19
+ "doc:documenter": "api-documenter markdown -i temp -o ../../documentation/docs/web-sdk/api",
20
+ "lint": "eslint --ext .ts src/ --fix",
21
+ "clean": "rimraf dist && rimraf temp",
22
+ "test": "jest"
23
+ },
24
+ "dependencies": {
25
+ "@metamask/detect-provider": "^1.2.0",
26
+ "@tinycloudlabs/web-core": "workspace:*",
27
+ "@tinycloudlabs/web-sdk-wasm": "workspace:*",
28
+ "assert": "^2.1.0",
29
+ "axios": "^1.7.9",
30
+ "browser": "^0.2.6",
31
+ "buffer": "^6.0.3",
32
+ "cross-env": "5.2.1",
33
+ "ethers": "^5.7.2",
34
+ "events": "^3.3.0",
35
+ "https-browserify": "^1.0.0",
36
+ "lodash.merge": "^4.6.2",
37
+ "os-browserify": "^0.3.0",
38
+ "path-browserify": "^1.0.1",
39
+ "process": "^0.11.10",
40
+ "siwe": "^3.0.0",
41
+ "stream-browserify": "^3.0.0",
42
+ "stream-http": "^3.2.0",
43
+ "url": "^0.11.4"
44
+ },
45
+ "devDependencies": {
46
+ "@babel/preset-env": "^7.26.7",
47
+ "@microsoft/api-documenter": "^7.26.5",
48
+ "@microsoft/api-extractor": "^7.49.1",
49
+ "@types/jest": "^27.5.2",
50
+ "@types/lodash.merge": "^4.6.9",
51
+ "@types/node": "^18.19.74",
52
+ "@types/webpack": "^5.28.5",
53
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
54
+ "@typescript-eslint/parser": "^5.62.0",
55
+ "@webpack-cli/generators": "^3.0.7",
56
+ "babel-jest": "^28.1.3",
57
+ "clean-webpack-plugin": "^4.0.0",
58
+ "copy-webpack-plugin": "^11.0.0",
59
+ "declaration-bundler-webpack-plugin": "^1.0.3",
60
+ "eslint": "^8.57.1",
61
+ "eslint-config-airbnb-base": "^15.0.0",
62
+ "eslint-plugin-import": "^2.31.0",
63
+ "gh-pages": "^4.0.0",
64
+ "ts-loader": "^9.5.2",
65
+ "typescript": "^4.9.5",
66
+ "util": "^0.12.5",
67
+ "webpack": "^5.97.1",
68
+ "webpack-cli": "^4.10.0"
69
+ },
70
+ "files": [
71
+ "dist"
72
+ ]
73
+ }