@tinycloudlabs/web-sdk-wasm 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.
- package/README.md +92 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +1171 -0
- package/dist/tinycloud_web_sdk_rs.d.ts +227 -0
- package/package.json +33 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Initialise console-error-panic-hook to improve debug output for panics.
|
|
5
|
+
*
|
|
6
|
+
* Run once on initialisation.
|
|
7
|
+
*/
|
|
8
|
+
export function initPanicHook(): void;
|
|
9
|
+
export function makeOrbitId(address: string, chainId: number, name?: string | null): string;
|
|
10
|
+
export function prepareSession(config: string): Promise<any>;
|
|
11
|
+
export function completeSessionSetup(config: string): string;
|
|
12
|
+
export function invoke(session: string, service: string, path: string, action: string): Promise<any>;
|
|
13
|
+
export function generateHostSIWEMessage(config: string): string;
|
|
14
|
+
export function siweToDelegationHeaders(signedSIWEMessage: string): string;
|
|
15
|
+
|
|
16
|
+
export type ExtraFields = {
|
|
17
|
+
/** Any extra fields that are needed for the capability.
|
|
18
|
+
* This object must be serializable with JSON.stringify().
|
|
19
|
+
*/
|
|
20
|
+
[key: string]: any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export type SiweConfig = {
|
|
26
|
+
/**Ethereum address performing the signing conformant to capitalization
|
|
27
|
+
* encoded checksum specified in EIP-55 where applicable. */
|
|
28
|
+
address: string;
|
|
29
|
+
/**EIP-155 Chain ID to which the session is bound, and the network where
|
|
30
|
+
* Contract Accounts must be resolved. */
|
|
31
|
+
chainId: number;
|
|
32
|
+
/**RFC 4501 dns authority that is requesting the signing. */
|
|
33
|
+
domain: string;
|
|
34
|
+
/**Randomized token used to prevent replay attacks, at least 8 alphanumeric
|
|
35
|
+
* characters. */
|
|
36
|
+
nonce?: string;
|
|
37
|
+
/**ISO 8601 datetime string of the current time. */
|
|
38
|
+
issuedAt: string;
|
|
39
|
+
/**ISO 8601 datetime string that, if present, indicates when the signed
|
|
40
|
+
* authentication message is no longer valid. */
|
|
41
|
+
expirationTime?: string;
|
|
42
|
+
/**ISO 8601 datetime string that, if present, indicates when the signed
|
|
43
|
+
* authentication message will become valid. */
|
|
44
|
+
notBefore?: string;
|
|
45
|
+
/**System-specific identifier that may be used to uniquely refer to the
|
|
46
|
+
* sign-in request. */
|
|
47
|
+
requestId?: string;
|
|
48
|
+
/**List of information or references to information the user wishes to have
|
|
49
|
+
* resolved as part of authentication by the relying party. They are
|
|
50
|
+
* expressed as RFC 3986 URIs separated by `\n- `. */
|
|
51
|
+
resources?: string[];
|
|
52
|
+
/**Human-readable ASCII assertion that the user will sign, and it must not
|
|
53
|
+
* contain `\n`. */
|
|
54
|
+
statement?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Configuration object for starting a TinyCloud session.
|
|
61
|
+
*/
|
|
62
|
+
export type SessionConfig = {
|
|
63
|
+
/** Actions that the session key will be permitted to perform, organized by service and path */
|
|
64
|
+
actions: { [service: string]: { [key: string]: string[] }},
|
|
65
|
+
/** Ethereum address. */
|
|
66
|
+
address: string,
|
|
67
|
+
/** Chain ID. */
|
|
68
|
+
chainId: number,
|
|
69
|
+
/** Domain of the webpage. */
|
|
70
|
+
domain: string,
|
|
71
|
+
/** Current time for SIWE message. */
|
|
72
|
+
issuedAt: string,
|
|
73
|
+
/** The orbit that is the target resource of the delegation. */
|
|
74
|
+
orbitId: string,
|
|
75
|
+
/** The earliest time that the session will be valid from. */
|
|
76
|
+
notBefore?: string,
|
|
77
|
+
/** The latest time that the session will be valid until. */
|
|
78
|
+
expirationTime: string,
|
|
79
|
+
/** Optional parent delegations to inherit and attenuate */
|
|
80
|
+
parents?: string[]
|
|
81
|
+
/** Optional jwk to delegate to */
|
|
82
|
+
jwk?: object
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* A TinyCloud session.
|
|
89
|
+
*/
|
|
90
|
+
export type Session = {
|
|
91
|
+
/** The delegation from the user to the session key. */
|
|
92
|
+
delegationHeader: { Authorization: string },
|
|
93
|
+
/** The delegation reference from the user to the session key. */
|
|
94
|
+
delegationCid: string,
|
|
95
|
+
/** The session key. */
|
|
96
|
+
jwk: object,
|
|
97
|
+
/** The orbit that the session key is permitted to perform actions against. */
|
|
98
|
+
orbitId: string,
|
|
99
|
+
/** The verification method of the session key. */
|
|
100
|
+
verificationMethod: string,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Configuration object for generating a TinyCloud Orbit Host Delegation SIWE message.
|
|
107
|
+
*/
|
|
108
|
+
export type HostConfig = {
|
|
109
|
+
/** Ethereum address. */
|
|
110
|
+
address: string,
|
|
111
|
+
/** Chain ID. */
|
|
112
|
+
chainId: number,
|
|
113
|
+
/** Domain of the webpage. */
|
|
114
|
+
domain: string,
|
|
115
|
+
/** Current time for SIWE message. */
|
|
116
|
+
issuedAt: string,
|
|
117
|
+
/** The orbit that is the target resource of the delegation. */
|
|
118
|
+
orbitId: string,
|
|
119
|
+
/** The peer that is the target/invoker in the delegation. */
|
|
120
|
+
peerId: string,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
export class TCWSessionManager {
|
|
125
|
+
free(): void;
|
|
126
|
+
/**
|
|
127
|
+
* Initialize a new TinyCloudWebSessionManager.
|
|
128
|
+
*/
|
|
129
|
+
constructor();
|
|
130
|
+
/**
|
|
131
|
+
* Reset the SIWE message builder to its initial state.
|
|
132
|
+
*/
|
|
133
|
+
resetBuilder(): void;
|
|
134
|
+
/**
|
|
135
|
+
* Build a SIWE message for signing.
|
|
136
|
+
*/
|
|
137
|
+
build(config: SiweConfig, key_id?: string | null, custom_uri?: string | null): Promise<string>;
|
|
138
|
+
/**
|
|
139
|
+
* Add default actions to a capability.
|
|
140
|
+
*/
|
|
141
|
+
addDefaultActions(namespace: string, defaultActions: string[]): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Add actions for a specific target to a capability.
|
|
144
|
+
*/
|
|
145
|
+
addTargetedActions(namespace: string, target: string, actions: string[]): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Add extra fields to a capability.
|
|
148
|
+
*/
|
|
149
|
+
addExtraFields(namespace: string, extraFields: ExtraFields): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Create a new session key with the given key ID (Defaults to 'default').
|
|
152
|
+
*/
|
|
153
|
+
createSessionKey(key_id?: string | null): string;
|
|
154
|
+
/**
|
|
155
|
+
* List the available session keys.
|
|
156
|
+
*/
|
|
157
|
+
listSessionKeys(): any;
|
|
158
|
+
/**
|
|
159
|
+
* Rename the key_id to retrieve session data.
|
|
160
|
+
*/
|
|
161
|
+
renameSessionKeyId(old_key_id: string, new_key_id: string): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Get the DID associated with a the session key key_id.
|
|
164
|
+
*/
|
|
165
|
+
getDID(key_id?: string | null): Promise<string>;
|
|
166
|
+
/**
|
|
167
|
+
* Get the full JWK associated with a the session key key_id.
|
|
168
|
+
*/
|
|
169
|
+
jwk(key_id?: string | null): string | undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
173
|
+
|
|
174
|
+
export interface InitOutput {
|
|
175
|
+
readonly memory: WebAssembly.Memory;
|
|
176
|
+
readonly __wbg_tcwsessionmanager_free: (a: number, b: number) => void;
|
|
177
|
+
readonly tcwsessionmanager_new: () => [number, number, number];
|
|
178
|
+
readonly tcwsessionmanager_resetBuilder: (a: number) => void;
|
|
179
|
+
readonly tcwsessionmanager_build: (a: number, b: any, c: number, d: number, e: number, f: number) => any;
|
|
180
|
+
readonly tcwsessionmanager_addDefaultActions: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
181
|
+
readonly tcwsessionmanager_addTargetedActions: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
182
|
+
readonly tcwsessionmanager_addExtraFields: (a: number, b: number, c: number, d: any) => number;
|
|
183
|
+
readonly tcwsessionmanager_createSessionKey: (a: number, b: number, c: number) => [number, number, number, number];
|
|
184
|
+
readonly tcwsessionmanager_listSessionKeys: (a: number) => [number, number, number];
|
|
185
|
+
readonly tcwsessionmanager_renameSessionKeyId: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
186
|
+
readonly tcwsessionmanager_getDID: (a: number, b: number, c: number) => any;
|
|
187
|
+
readonly tcwsessionmanager_jwk: (a: number, b: number, c: number) => [number, number];
|
|
188
|
+
readonly initPanicHook: () => void;
|
|
189
|
+
readonly makeOrbitId: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
190
|
+
readonly prepareSession: (a: number, b: number) => any;
|
|
191
|
+
readonly completeSessionSetup: (a: number, b: number) => [number, number, number, number];
|
|
192
|
+
readonly invoke: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => any;
|
|
193
|
+
readonly generateHostSIWEMessage: (a: number, b: number) => [number, number, number, number];
|
|
194
|
+
readonly siweToDelegationHeaders: (a: number, b: number) => [number, number, number, number];
|
|
195
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
196
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
197
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
198
|
+
readonly __externref_table_alloc: () => number;
|
|
199
|
+
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
200
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
201
|
+
readonly __wbindgen_export_6: WebAssembly.Table;
|
|
202
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
203
|
+
readonly closure1383_externref_shim: (a: number, b: number, c: any) => void;
|
|
204
|
+
readonly closure2024_externref_shim: (a: number, b: number, c: any, d: any) => void;
|
|
205
|
+
readonly __wbindgen_start: () => void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
209
|
+
/**
|
|
210
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
211
|
+
* a precompiled `WebAssembly.Module`.
|
|
212
|
+
*
|
|
213
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
214
|
+
*
|
|
215
|
+
* @returns {InitOutput}
|
|
216
|
+
*/
|
|
217
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
221
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
222
|
+
*
|
|
223
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
224
|
+
*
|
|
225
|
+
* @returns {Promise<InitOutput>}
|
|
226
|
+
*/
|
|
227
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tinycloudlabs/web-sdk-wasm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"author": "TinyCloud, Inc.",
|
|
7
|
+
"license": "Apache-2.0 OR MIT",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "bun build-dev",
|
|
10
|
+
"build-dev": "wasm-pack build --dev --target web",
|
|
11
|
+
"build-release": "wasm-pack build --release --target web",
|
|
12
|
+
"bundle": "rollup -c && $PWD/fixup-types.sh",
|
|
13
|
+
"clean": "rm -rf dist pkg",
|
|
14
|
+
"dev": "yarn build-dev && yarn bundle",
|
|
15
|
+
"release": "yarn build-release && yarn bundle",
|
|
16
|
+
"fmt": "prettier -w src package.json rollup.config.js tsconfig.json",
|
|
17
|
+
"publish-gh": "npm config set @tinycloudlabs:registry=https://npm.pkg.github.com && npm publish",
|
|
18
|
+
"publish-npm": "npm config set @tinycloudlabs:registry=https://registry.npmjs.org && npm publish --access public"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@changesets/cli": "^2.27.12",
|
|
22
|
+
"@rollup/plugin-wasm": "^5.2.0",
|
|
23
|
+
"prettier": "^2.8.8",
|
|
24
|
+
"rollup": "^2.79.2",
|
|
25
|
+
"rollup-plugin-typescript2": "^0.32.1",
|
|
26
|
+
"tslib": "^2.8.1",
|
|
27
|
+
"typescript": "^4.9.5"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"tsconfig.json",
|
|
31
|
+
"dist"
|
|
32
|
+
]
|
|
33
|
+
}
|