@fastpix/fastpix-node 2.0.1 → 2.0.3
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/LICENSE +21 -201
- package/README.md +273 -155
- package/dist/commonjs/funcs/signingKeysGetSigningKeyById.d.ts +2 -2
- package/dist/commonjs/funcs/signingKeysGetSigningKeyById.js +2 -2
- package/dist/commonjs/models/operations/getdrmconfiguration.d.ts +2 -2
- package/dist/commonjs/models/operations/getdrmconfiguration.d.ts.map +1 -1
- package/dist/commonjs/models/operations/getdrmconfiguration.js +2 -2
- package/dist/commonjs/models/operations/getdrmconfiguration.js.map +1 -1
- package/dist/commonjs/sdk/signingkeys.d.ts +2 -2
- package/dist/commonjs/sdk/signingkeys.js +2 -2
- package/dist/esm/funcs/signingKeysGetSigningKeyById.d.ts +2 -2
- package/dist/esm/funcs/signingKeysGetSigningKeyById.js +2 -2
- package/dist/esm/models/operations/getdrmconfiguration.d.ts +2 -2
- package/dist/esm/models/operations/getdrmconfiguration.d.ts.map +1 -1
- package/dist/esm/models/operations/getdrmconfiguration.js +2 -2
- package/dist/esm/models/operations/getdrmconfiguration.js.map +1 -1
- package/dist/esm/sdk/signingkeys.d.ts +2 -2
- package/dist/esm/sdk/signingkeys.js +2 -2
- package/package.json +2 -2
- package/samples/ai/ai-features.ts +194 -0
- package/samples/analytics/dimensions.ts +113 -0
- package/samples/analytics/errors.ts +133 -0
- package/samples/analytics/metrics.ts +117 -0
- package/samples/analytics/views.ts +120 -0
- package/samples/common/config.ts +84 -0
- package/samples/common/setup.ts +42 -0
- package/samples/comprehensive-example.ts +267 -0
- package/samples/index.ts +224 -0
- package/samples/live/live-playback.ts +104 -0
- package/samples/live/manage-live-stream.ts +176 -0
- package/samples/live/start-live-stream.ts +91 -0
- package/samples/media/input-video.ts +65 -0
- package/samples/media/manage-videos.ts +166 -0
- package/samples/media/playback.ts +89 -0
- package/samples/media/playlist.ts +201 -0
- package/samples/package.json +51 -0
- package/samples/security/drm-configurations.ts +125 -0
- package/samples/security/signing-keys.ts +154 -0
- package/src/funcs/signingKeysGetSigningKeyById.ts +2 -2
- package/src/models/operations/getdrmconfiguration.ts +4 -4
- package/src/sdk/signingkeys.ts +2 -2
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signing Keys API Samples
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the Signing Keys API to:
|
|
5
|
+
* - Create signing keys
|
|
6
|
+
* - List signing keys
|
|
7
|
+
* - Get signing key by ID
|
|
8
|
+
* - Delete signing keys
|
|
9
|
+
*
|
|
10
|
+
* Run this sample:
|
|
11
|
+
* npx tsx security/signing-keys.ts
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createFastpixClient, runSample } from "../common/setup.js";
|
|
15
|
+
import { logResponse } from "../common/config.js";
|
|
16
|
+
|
|
17
|
+
let createdKeyId: string | undefined;
|
|
18
|
+
|
|
19
|
+
async function createSigningKey() {
|
|
20
|
+
const fastpix = createFastpixClient();
|
|
21
|
+
|
|
22
|
+
const result = await fastpix.signingKeys.createSigningKey();
|
|
23
|
+
|
|
24
|
+
if (result.data?.id) {
|
|
25
|
+
createdKeyId = result.data.id;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
logResponse("Create Signing Key", result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function listSigningKeys() {
|
|
33
|
+
const fastpix = createFastpixClient();
|
|
34
|
+
|
|
35
|
+
const result = await fastpix.signingKeys.listSigningKeys();
|
|
36
|
+
|
|
37
|
+
logResponse("List Signing Keys", result);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function getSigningKeyById() {
|
|
42
|
+
if (!createdKeyId) {
|
|
43
|
+
console.log("⚠️ No signing key ID available. Run createSigningKey first.");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const fastpix = createFastpixClient();
|
|
48
|
+
|
|
49
|
+
const result = await fastpix.signingKeys.getSigningKeyById({
|
|
50
|
+
keyId: createdKeyId,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
logResponse("Get Signing Key by ID", result);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function deleteSigningKey() {
|
|
58
|
+
if (!createdKeyId) {
|
|
59
|
+
console.log("⚠️ No signing key ID available. Run createSigningKey first.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const fastpix = createFastpixClient();
|
|
64
|
+
|
|
65
|
+
const result = await fastpix.signingKeys.deleteSigningKey({
|
|
66
|
+
keyId: createdKeyId,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
logResponse("Delete Signing Key", result);
|
|
70
|
+
createdKeyId = undefined; // Reset the ID since key is deleted
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function demonstrateKeyUsage() {
|
|
75
|
+
const fastpix = createFastpixClient();
|
|
76
|
+
|
|
77
|
+
console.log("\n🔐 Signing Key Usage Demonstration:");
|
|
78
|
+
console.log("===================================");
|
|
79
|
+
|
|
80
|
+
// Create a new signing key
|
|
81
|
+
const createResult = await fastpix.signingKeys.createSigningKey();
|
|
82
|
+
const keyId = createResult.data?.id;
|
|
83
|
+
const privateKey = createResult.data?.privateKey;
|
|
84
|
+
|
|
85
|
+
if (keyId && privateKey) {
|
|
86
|
+
console.log(`\n✅ Created signing key with ID: ${keyId}`);
|
|
87
|
+
console.log(`📝 Private key (Base64 encoded): ${privateKey.substring(0, 50)}...`);
|
|
88
|
+
|
|
89
|
+
console.log("\n💡 Usage Instructions:");
|
|
90
|
+
console.log("1. Store the private key securely");
|
|
91
|
+
console.log("2. Use the private key to sign JWTs for authentication");
|
|
92
|
+
console.log("3. FastPix will use the public key to verify signed tokens");
|
|
93
|
+
console.log("4. The key ID can be used to reference this key pair");
|
|
94
|
+
|
|
95
|
+
// Get the key details
|
|
96
|
+
const keyDetails = await fastpix.signingKeys.getSigningKeyById({ keyId });
|
|
97
|
+
console.log(`\n📊 Key Details:`);
|
|
98
|
+
console.log(` ID: ${keyDetails.data?.id}`);
|
|
99
|
+
console.log(` Created: ${keyDetails.data?.createdAt}`);
|
|
100
|
+
console.log(` Status: ${keyDetails.data?.status || 'Active'}`);
|
|
101
|
+
|
|
102
|
+
// Clean up
|
|
103
|
+
await fastpix.signingKeys.deleteSigningKey({ keyId });
|
|
104
|
+
console.log(`\n🗑️ Cleaned up signing key: ${keyId}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return createResult;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function manageMultipleKeys() {
|
|
111
|
+
const fastpix = createFastpixClient();
|
|
112
|
+
|
|
113
|
+
console.log("\n🔑 Managing Multiple Signing Keys:");
|
|
114
|
+
console.log("==================================");
|
|
115
|
+
|
|
116
|
+
const keyIds = [];
|
|
117
|
+
|
|
118
|
+
// Create multiple keys
|
|
119
|
+
for (let i = 1; i <= 3; i++) {
|
|
120
|
+
const result = await fastpix.signingKeys.createSigningKey();
|
|
121
|
+
if (result.data?.id) {
|
|
122
|
+
keyIds.push(result.data.id);
|
|
123
|
+
console.log(`✅ Created key ${i}: ${result.data.id}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// List all keys
|
|
128
|
+
const allKeys = await fastpix.signingKeys.listSigningKeys();
|
|
129
|
+
console.log(`\n📋 Total keys: ${allKeys.data?.keys?.length || 0}`);
|
|
130
|
+
|
|
131
|
+
// Clean up all created keys
|
|
132
|
+
for (const keyId of keyIds) {
|
|
133
|
+
await fastpix.signingKeys.deleteSigningKey({ keyId });
|
|
134
|
+
console.log(`🗑️ Deleted key: ${keyId}`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return allKeys;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function main() {
|
|
141
|
+
console.log("🔐 Signing Keys API Samples");
|
|
142
|
+
console.log("============================");
|
|
143
|
+
|
|
144
|
+
await runSample("Create Signing Key", createSigningKey);
|
|
145
|
+
await runSample("List Signing Keys", listSigningKeys);
|
|
146
|
+
await runSample("Get Signing Key by ID", getSigningKeyById);
|
|
147
|
+
await runSample("Demonstrate Key Usage", demonstrateKeyUsage);
|
|
148
|
+
await runSample("Manage Multiple Keys", manageMultipleKeys);
|
|
149
|
+
|
|
150
|
+
// Uncomment to delete the signing key (be careful!)
|
|
151
|
+
// await runSample("Delete Signing Key", deleteSigningKey);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
main().catch(console.error);
|
|
@@ -36,8 +36,8 @@ import { Result } from "../types/fp.js";
|
|
|
36
36
|
*
|
|
37
37
|
* ```
|
|
38
38
|
* {
|
|
39
|
-
* "kid": "
|
|
40
|
-
* "aud": "media:
|
|
39
|
+
* "kid": "your-signing-key-id",
|
|
40
|
+
* "aud": "media:your-media-id",
|
|
41
41
|
* "iss": "fastpix.io",
|
|
42
42
|
* "sub": "",
|
|
43
43
|
* "iat": 1706703204,
|
|
@@ -20,7 +20,7 @@ export type GetDrmConfigurationRequest = {
|
|
|
20
20
|
*/
|
|
21
21
|
export type GetDrmConfigurationResponse = {
|
|
22
22
|
success?: boolean | undefined;
|
|
23
|
-
data?:
|
|
23
|
+
data?: models.DrmIdResponse | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* Pagination organizes content into pages for better readability and navigation.
|
|
26
26
|
*/
|
|
@@ -91,14 +91,14 @@ export const GetDrmConfigurationResponse$inboundSchema: z.ZodType<
|
|
|
91
91
|
unknown
|
|
92
92
|
> = z.object({
|
|
93
93
|
success: z.boolean().optional(),
|
|
94
|
-
data:
|
|
94
|
+
data: models.DrmIdResponse$inboundSchema.optional(),
|
|
95
95
|
pagination: models.Pagination$inboundSchema.optional(),
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
/** @internal */
|
|
99
99
|
export type GetDrmConfigurationResponse$Outbound = {
|
|
100
100
|
success?: boolean | undefined;
|
|
101
|
-
data?:
|
|
101
|
+
data?: models.DrmIdResponse$Outbound | undefined;
|
|
102
102
|
pagination?: models.Pagination$Outbound | undefined;
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -109,7 +109,7 @@ export const GetDrmConfigurationResponse$outboundSchema: z.ZodType<
|
|
|
109
109
|
GetDrmConfigurationResponse
|
|
110
110
|
> = z.object({
|
|
111
111
|
success: z.boolean().optional(),
|
|
112
|
-
data:
|
|
112
|
+
data: models.DrmIdResponse$outboundSchema.optional(),
|
|
113
113
|
pagination: models.Pagination$outboundSchema.optional(),
|
|
114
114
|
});
|
|
115
115
|
|
package/src/sdk/signingkeys.ts
CHANGED
|
@@ -107,8 +107,8 @@ export class SigningKeys extends ClientSDK {
|
|
|
107
107
|
*
|
|
108
108
|
* ```
|
|
109
109
|
* {
|
|
110
|
-
* "kid": "
|
|
111
|
-
* "aud": "media:
|
|
110
|
+
* "kid": "your-signing-key-id",
|
|
111
|
+
* "aud": "media:your-media-id",
|
|
112
112
|
* "iss": "fastpix.io",
|
|
113
113
|
* "sub": "",
|
|
114
114
|
* "iat": 1706703204,
|