sbcwallet 0.0.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.
Files changed (67) hide show
  1. package/.env.example +10 -0
  2. package/.github/workflows/build.yml +66 -0
  3. package/.github/workflows/release.yml +57 -0
  4. package/APPLE_WALLET_SETUP.md +318 -0
  5. package/GOOGLE_WALLET_SETUP.md +473 -0
  6. package/LICENSE +201 -0
  7. package/README.md +187 -0
  8. package/dist/adapters/apple.d.ts +10 -0
  9. package/dist/adapters/apple.js +153 -0
  10. package/dist/adapters/google.d.ts +26 -0
  11. package/dist/adapters/google.js +431 -0
  12. package/dist/api/unified.d.ts +67 -0
  13. package/dist/api/unified.js +375 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.js +11 -0
  16. package/dist/profiles/healthcare/index.d.ts +91 -0
  17. package/dist/profiles/healthcare/index.js +151 -0
  18. package/dist/profiles/logistics/index.d.ts +91 -0
  19. package/dist/profiles/logistics/index.js +152 -0
  20. package/dist/profiles/loyalty/index.d.ts +91 -0
  21. package/dist/profiles/loyalty/index.js +81 -0
  22. package/dist/templates/apple/child.json +59 -0
  23. package/dist/templates/apple/parent.json +54 -0
  24. package/dist/templates/google/child_object.json +38 -0
  25. package/dist/templates/google/loyalty_class.json +7 -0
  26. package/dist/templates/google/loyalty_object.json +29 -0
  27. package/dist/templates/google/parent_class.json +10 -0
  28. package/dist/templates/google/parent_object.json +33 -0
  29. package/dist/types.d.ts +422 -0
  30. package/dist/types.js +80 -0
  31. package/dist/utils/progress-image.d.ts +23 -0
  32. package/dist/utils/progress-image.js +94 -0
  33. package/examples/.loyalty-fixed-state.json +10 -0
  34. package/examples/claim-flow.ts +163 -0
  35. package/examples/loyalty-admin-server.js +207 -0
  36. package/examples/loyalty-admin.html +260 -0
  37. package/examples/loyalty-fixed-card-server.js +288 -0
  38. package/examples/loyalty-flow.ts +78 -0
  39. package/examples/loyalty-google-issue.js +115 -0
  40. package/package.json +51 -0
  41. package/scripts/copy-assets.js +35 -0
  42. package/scripts/smoke-dist-import.js +39 -0
  43. package/setup-google-class.js +97 -0
  44. package/setup-google-class.ts +105 -0
  45. package/src/adapters/apple.ts +193 -0
  46. package/src/adapters/google.ts +521 -0
  47. package/src/api/unified.ts +487 -0
  48. package/src/index.ts +74 -0
  49. package/src/profiles/healthcare/index.ts +157 -0
  50. package/src/profiles/logistics/index.ts +158 -0
  51. package/src/profiles/loyalty/index.ts +87 -0
  52. package/src/templates/apple/child.json +59 -0
  53. package/src/templates/apple/parent.json +54 -0
  54. package/src/templates/google/child_object.json +38 -0
  55. package/src/templates/google/loyalty_class.json +7 -0
  56. package/src/templates/google/loyalty_object.json +29 -0
  57. package/src/templates/google/parent_class.json +10 -0
  58. package/src/templates/google/parent_object.json +33 -0
  59. package/src/types.ts +324 -0
  60. package/src/utils/progress-image.ts +130 -0
  61. package/test-google-wallet.js +78 -0
  62. package/test-google-wallet.ts +94 -0
  63. package/tests/adapters.test.ts +244 -0
  64. package/tests/loyalty.test.ts +39 -0
  65. package/tests/unified.test.ts +388 -0
  66. package/tsconfig.json +19 -0
  67. package/vitest.config.ts +12 -0
@@ -0,0 +1,473 @@
1
+ # Google Wallet Setup Guide
2
+
3
+ Complete guide for setting up Google Wallet pass generation with sbcwallet.
4
+
5
+ ## Prerequisites
6
+
7
+ - ✅ Google Cloud Account - **FREE** (no purchase required!)
8
+ - ✅ Google Pay & Wallet Console access - **FREE**
9
+ - ✅ sbcwallet package (already built)
10
+
11
+ ---
12
+
13
+ ## 💰 Cost Comparison
14
+
15
+ | Platform | Cost | What You Get |
16
+ |----------|------|--------------|
17
+ | **Apple Wallet** | $99/year | Apple Developer Program membership |
18
+ | **Google Wallet** | **FREE** | Full access to Google Wallet API |
19
+
20
+ **No payment required for Google Wallet!** 🎉
21
+
22
+ ---
23
+
24
+ ## Step 1: Set Up Google Cloud Project
25
+
26
+ ### A. Create Google Cloud Project
27
+
28
+ 1. Go to [console.cloud.google.com](https://console.cloud.google.com)
29
+ 2. Click **Select a project** → **NEW PROJECT**
30
+ 3. Fill in:
31
+ - **Project name**: `sbcwallet Pass`
32
+ - **Organization**: (optional)
33
+ 4. Click **CREATE**
34
+
35
+ ### B. Enable Google Wallet API
36
+
37
+ 1. In your project, go to **APIs & Services** → **Library**
38
+ 2. Search for "**Google Wallet API**"
39
+ 3. Click on it → Click **ENABLE**
40
+
41
+ ---
42
+
43
+ ## Step 2: Create Service Account
44
+
45
+ ### A. Create Service Account
46
+
47
+ 1. Go to **APIs & Services** → **Credentials**
48
+ 2. Click **+ CREATE CREDENTIALS** → **Service account**
49
+ 3. Fill in:
50
+ - **Service account name**: `sbcwallet-pass-service`
51
+ - **Service account ID**: `sbcwallet-pass-service` (auto-filled)
52
+ - **Description**: Service account for sbcwallet Pass generation
53
+ 4. Click **CREATE AND CONTINUE**
54
+ 5. Skip optional steps → Click **DONE**
55
+
56
+ ### B. Create Service Account Key
57
+
58
+ 1. Click on the service account you just created
59
+ 2. Go to **KEYS** tab
60
+ 3. Click **ADD KEY** → **Create new key**
61
+ 4. Choose **JSON** format
62
+ 5. Click **CREATE**
63
+ 6. Save the JSON file as: `/Users/przpgo/code/sbcwallet/pass/certs/google-credentials.json`
64
+
65
+ ---
66
+
67
+ ## Step 3: Get Issuer ID
68
+
69
+ ### A. Register for Google Pay & Wallet Console
70
+
71
+ 1. Go to [pay.google.com/business/console](https://pay.google.com/business/console)
72
+ 2. Sign in with the same Google account
73
+ 3. If first time:
74
+ - Accept Terms of Service
75
+ - Fill in business information (can use personal info for testing)
76
+
77
+ ### B. Create Issuer Account
78
+
79
+ 1. In Google Pay & Wallet Console, go to **Google Wallet API**
80
+ 2. Click **Create Issuer Account** (if not already created)
81
+ 3. Fill in:
82
+ - **Issuer name**: sbcwallet
83
+ - **Contact email**: your@email.com
84
+ 4. Your **Issuer ID** will be shown (format: `3388000000012345678`)
85
+ 5. **Save this ID** - you'll need it!
86
+
87
+ ---
88
+
89
+ ## Step 4: Grant Permissions
90
+
91
+ ### A. Add Service Account to Issuer
92
+
93
+ 1. In Google Pay & Wallet Console → **Google Wallet API**
94
+ 2. Click on your Issuer account
95
+ 3. Click **Add user** or **Manage users**
96
+ 4. Add your service account email:
97
+ - Format: `sbcwallet-pass-service@sbcwallet-pass.iam.gserviceaccount.com`
98
+ - Role: **Developer** or **Owner**
99
+ 5. Click **INVITE**
100
+
101
+ ---
102
+
103
+ ## Step 5: Configure Environment Variables
104
+
105
+ Create or update your `.env` file:
106
+
107
+ ```bash
108
+ cd /Users/przpgo/code/sbcwallet/pass
109
+
110
+ cat >> .env << 'EOF'
111
+
112
+ # Google Wallet Configuration
113
+ GOOGLE_ISSUER_ID=3388000000012345678
114
+ GOOGLE_SA_JSON=./certs/google-credentials.json
115
+ EOF
116
+ ```
117
+
118
+ Replace `3388000000012345678` with your actual Issuer ID from Step 3.
119
+
120
+ ---
121
+
122
+ ## Step 6: Install Google Auth Library
123
+
124
+ ```bash
125
+ npm install google-auth-library
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Step 7: Test Google Wallet Integration
131
+
132
+ Create a test script:
133
+
134
+ ```bash
135
+ cat > test-google-wallet.ts << 'EOF'
136
+ import { createParentSchedule, createChildTicket, getGoogleObject } from './dist/index.js'
137
+ import 'dotenv/config'
138
+
139
+ async function testGoogleWallet() {
140
+ console.log('🧪 Testing Google Wallet Pass Generation\n')
141
+
142
+ // Create parent
143
+ const parent = await createParentSchedule({
144
+ profile: 'logistics',
145
+ programName: 'Test Yard Veracruz',
146
+ site: 'Patio Gate 3',
147
+ window: {
148
+ from: '2025-10-20T08:00:00-06:00',
149
+ to: '2025-10-20T12:00:00-06:00',
150
+ tz: 'America/Mexico_City'
151
+ }
152
+ })
153
+
154
+ console.log('✅ Parent created:', parent.id)
155
+
156
+ // Create child
157
+ const child = await createChildTicket({
158
+ profile: 'logistics',
159
+ parentId: parent.id,
160
+ plate: 'TEST123',
161
+ carrier: 'Test Transport',
162
+ client: 'Test Client'
163
+ })
164
+
165
+ console.log('✅ Child created:', child.id)
166
+
167
+ // Generate Google Wallet object
168
+ try {
169
+ const { object, saveUrl } = await getGoogleObject('child', child)
170
+
171
+ console.log('\n✅ Google Wallet Object Generated!')
172
+ console.log('\n📋 Object Details:')
173
+ console.log(JSON.stringify(object, null, 2))
174
+
175
+ console.log('\n🔗 Save URL:')
176
+ console.log(saveUrl)
177
+
178
+ console.log('\n📱 To test on Android:')
179
+ console.log('1. Open the Save URL on your Android device')
180
+ console.log('2. Or scan QR code (generate from Save URL)')
181
+ console.log('3. Pass will be added to Google Wallet')
182
+ } catch (error) {
183
+ console.error('❌ Error generating pass:', error)
184
+ throw error
185
+ }
186
+ }
187
+
188
+ testGoogleWallet()
189
+ EOF
190
+ ```
191
+
192
+ ### Run the test:
193
+
194
+ ```bash
195
+ npm install dotenv
196
+ npx tsc test-google-wallet.ts --module ESNext --target ES2022 --moduleResolution node --esModuleInterop
197
+ node test-google-wallet.js
198
+ ```
199
+
200
+ Expected output:
201
+ ```
202
+ 🧪 Testing Google Wallet Pass Generation
203
+
204
+ ✅ Parent created: PES-2025-10-20-XXXX
205
+ ✅ Child created: TO-2025-10-20-XXXX-YYYY
206
+
207
+ ✅ Google Wallet Object Generated!
208
+
209
+ 📋 Object Details:
210
+ {
211
+ "id": "3388000000012345678.TO-2025-10-20-XXXX-YYYY",
212
+ "classId": "3388000000012345678.logistics_child",
213
+ "state": "ACTIVE",
214
+ "cardTitle": {
215
+ "header": "Transport Order",
216
+ "body": "TEST123"
217
+ },
218
+ ...
219
+ }
220
+
221
+ 🔗 Save URL:
222
+ https://pay.google.com/gp/v/save/3388000000012345678.TO-2025-10-20-XXXX-YYYY
223
+
224
+ 📱 To test on Android:
225
+ 1. Open the Save URL on your Android device
226
+ 2. Or scan QR code (generate from Save URL)
227
+ 3. Pass will be added to Google Wallet
228
+ ```
229
+
230
+ ---
231
+
232
+ ## Step 8: Create Generic Pass Class (One-time Setup)
233
+
234
+ Google Wallet requires creating a "class" before creating individual passes. Create this script:
235
+
236
+ ```typescript
237
+ // create-google-class.ts
238
+ import { GoogleAuth } from 'google-auth-library'
239
+ import 'dotenv/config'
240
+
241
+ const ISSUER_ID = process.env.GOOGLE_ISSUER_ID!
242
+ const SERVICE_ACCOUNT_FILE = process.env.GOOGLE_SA_JSON!
243
+
244
+ async function createGenericClass() {
245
+ const auth = new GoogleAuth({
246
+ keyFile: SERVICE_ACCOUNT_FILE,
247
+ scopes: ['https://www.googleapis.com/auth/wallet_object.issuer']
248
+ })
249
+
250
+ const client = await auth.getClient()
251
+ const baseUrl = 'https://walletobjects.googleapis.com/walletobjects/v1'
252
+
253
+ // Create class for logistics child (Transport Order)
254
+ const classId = `${ISSUER_ID}.logistics_child`
255
+ const classPayload = {
256
+ id: classId,
257
+ issuerName: 'sbcwallet',
258
+ reviewStatus: 'UNDER_REVIEW'
259
+ }
260
+
261
+ try {
262
+ const response = await client.request({
263
+ url: `${baseUrl}/genericClass`,
264
+ method: 'POST',
265
+ data: classPayload
266
+ })
267
+ console.log('✅ Class created:', classId)
268
+ console.log(response.data)
269
+ } catch (error: any) {
270
+ if (error.response?.status === 409) {
271
+ console.log('ℹ️ Class already exists:', classId)
272
+ } else {
273
+ console.error('❌ Error:', error.response?.data || error.message)
274
+ }
275
+ }
276
+ }
277
+
278
+ createGenericClass()
279
+ ```
280
+
281
+ Run once:
282
+ ```bash
283
+ npx tsc create-google-class.ts --module ESNext --target ES2022 --moduleResolution node --esModuleInterop
284
+ node create-google-class.js
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Step 9: Install Pass on Android
290
+
291
+ ### Option 1: Direct URL
292
+ 1. Open the Save URL on your Android device
293
+ 2. Tap **Save to Google Wallet**
294
+ 3. Pass appears in Google Wallet app
295
+
296
+ ### Option 2: QR Code
297
+ ```bash
298
+ # Generate QR code from Save URL
299
+ npm install qrcode
300
+ ```
301
+
302
+ ---
303
+
304
+ ## 🧩 If you see: "This pass is only used for testing"
305
+
306
+ This message is shown by Google Wallet when your issuer/classes are still in **test / under-review** mode.
307
+ In that state, only **allowlisted test accounts** (managed in the Google Pay & Wallet Console) can save the pass.
308
+
309
+ Fix:
310
+ 1. Open Google Pay & Wallet Console: https://pay.google.com/business/console
311
+ 2. Go to **Google Wallet API** → select your **Issuer**
312
+ 3. Add your Google account email under **Users** and/or **Test accounts** (wording varies)
313
+ 4. Retry the signed Save URL on the same Google account on your Android device
314
+
315
+ Notes:
316
+ - For true public/production distribution, your classes/issuer must pass Google's review process; until then, saving is restricted to allowlisted accounts.
317
+
318
+ ```javascript
319
+ import QRCode from 'qrcode'
320
+
321
+ const saveUrl = 'https://pay.google.com/gp/v/save/...'
322
+ QRCode.toFile('google-wallet-qr.png', saveUrl)
323
+ console.log('QR code saved to google-wallet-qr.png')
324
+ ```
325
+
326
+ Scan with Android camera → Opens in Google Wallet
327
+
328
+ ### Option 3: Add to Website
329
+ ```html
330
+ <a href="https://pay.google.com/gp/v/save/YOUR_OBJECT_ID">
331
+ <img src="https://pay.google.com/gp/v/resources/add-to-google-wallet-button.svg">
332
+ </a>
333
+ ```
334
+
335
+ ---
336
+
337
+ ## Step 10: Update Google Adapter (Production Ready)
338
+
339
+ For production, update the Google adapter to actually call the API:
340
+
341
+ ```typescript
342
+ // src/adapters/google.ts
343
+ import { GoogleAuth } from 'google-auth-library'
344
+
345
+ export class GoogleWalletAdapter {
346
+ private auth: GoogleAuth
347
+
348
+ constructor(config?: Partial<GooglePassConfig>) {
349
+ this.config = {
350
+ issuerId: config?.issuerId || process.env.GOOGLE_ISSUER_ID || '',
351
+ serviceAccountPath: config?.serviceAccountPath || process.env.GOOGLE_SA_JSON
352
+ }
353
+
354
+ this.auth = new GoogleAuth({
355
+ keyFile: this.config.serviceAccountPath,
356
+ scopes: ['https://www.googleapis.com/auth/wallet_object.issuer']
357
+ })
358
+ }
359
+
360
+ async createPassObject(object: GooglePassObject): Promise<void> {
361
+ const client = await this.auth.getClient()
362
+ const url = 'https://walletobjects.googleapis.com/walletobjects/v1/genericObject'
363
+
364
+ await client.request({
365
+ url,
366
+ method: 'POST',
367
+ data: object
368
+ })
369
+ }
370
+
371
+ // ... rest of implementation
372
+ }
373
+ ```
374
+
375
+ ---
376
+
377
+ ## Comparison: Apple vs Google Wallet
378
+
379
+ | Feature | Apple Wallet | Google Wallet |
380
+ |---------|--------------|---------------|
381
+ | **Cost** | $99/year | **FREE** ✅ |
382
+ | **Setup Time** | ~30 min | ~20 min |
383
+ | **Certificate Required** | Yes (complex) | No (JSON key) |
384
+ | **Distribution** | .pkpass file | URL/QR code |
385
+ | **Testing** | Need iPhone | Works on any device with browser |
386
+ | **Updates** | Push notifications | Automatic via API |
387
+ | **Platforms** | iOS only | Android + Web |
388
+
389
+ ---
390
+
391
+ ## Testing Checklist
392
+
393
+ - [ ] Google Cloud project created
394
+ - [ ] Google Wallet API enabled
395
+ - [ ] Service account created with JSON key
396
+ - [ ] Issuer ID obtained
397
+ - [ ] Service account added to issuer
398
+ - [ ] `.env` configured with credentials
399
+ - [ ] Test script runs successfully
400
+ - [ ] Pass class created
401
+ - [ ] Save URL works on Android
402
+ - [ ] Pass appears in Google Wallet
403
+
404
+ ---
405
+
406
+ ## Troubleshooting
407
+
408
+ ### 1. "Invalid Issuer ID"
409
+ - **Solution**: Verify Issuer ID format (should be 19 digits)
410
+ - Check: pay.google.com/business/console → Google Wallet API
411
+
412
+ ### 2. "Permission denied"
413
+ - **Solution**: Add service account email to issuer users
414
+ - Format: `service-name@project-id.iam.gserviceaccount.com`
415
+
416
+ ### 3. "Class not found"
417
+ - **Solution**: Run `create-google-class.ts` first
418
+ - Each profile/type needs its own class
419
+
420
+ ### 4. Save URL doesn't work
421
+ - **Solution**: URL format should be:
422
+ ```
423
+ https://pay.google.com/gp/v/save/ISSUER_ID.OBJECT_ID
424
+ ```
425
+
426
+ ### 5. "Insufficient authentication scopes"
427
+ - **Solution**: Check service account has correct scope:
428
+ ```
429
+ https://www.googleapis.com/auth/wallet_object.issuer
430
+ ```
431
+
432
+ ---
433
+
434
+ ## Production Checklist
435
+
436
+ ### Security
437
+ - [ ] Don't commit `google-credentials.json` to git
438
+ - [ ] Use environment variables for all credentials
439
+ - [ ] Rotate service account keys periodically
440
+ - [ ] Use separate service accounts for dev/prod
441
+
442
+ ### API Implementation
443
+ - [ ] Implement actual API calls (not just stubs)
444
+ - [ ] Add error handling and retries
445
+ - [ ] Implement pass updates via API
446
+ - [ ] Add webhook handlers for events
447
+
448
+ ### Distribution
449
+ - [ ] Generate signed JWTs for Save URLs (more secure)
450
+ - [ ] Implement QR code generation
451
+ - [ ] Add "Add to Google Wallet" buttons to website
452
+ - [ ] Support deep linking from mobile apps
453
+
454
+ ---
455
+
456
+ ## Resources
457
+
458
+ - [Google Wallet API Documentation](https://developers.google.com/wallet)
459
+ - [Generic Pass Reference](https://developers.google.com/wallet/generic/rest/v1/genericobject)
460
+ - [Google Cloud Console](https://console.cloud.google.com)
461
+ - [Google Pay & Wallet Console](https://pay.google.com/business/console)
462
+ - [Sample Code Repository](https://github.com/google-pay/wallet-samples)
463
+
464
+ ---
465
+
466
+ ## Next Steps
467
+
468
+ 1. **Complete basic setup** (Steps 1-7) - **FREE, takes 20 min**
469
+ 2. **Test on Android device** (Step 9)
470
+ 3. **Implement production API** (Step 10)
471
+ 4. **Add to your app/website**
472
+
473
+ **No purchase required - get started now!** 🚀
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.